#include<bits/stdc++.h>//万能头文件
using namespace std;
struct P {
char a;
int cnt;
}p[30];
bool book[30];
bool cmp(struct P x, struct P y)//sort中排序依据
{
return x.cnt < y.cnt;
}
int main() {
char s[200];
int k;
scanf("%s\n%d", s, &k);
for (int i = 0; i < 26; i++)
p[i].a = 'a' + i;
for (int i = 0; s[i] != '\0'; i++) {
p[s[i] - 'a'].cnt++;
}
sort(p, p + 26, cmp);
int strat, ans=0;//种类数
for (int i = 0; i < 26; i++) {
if (p[i].cnt) {
strat = i;
break;
}
}
for (int i = strat; i < 26; i++) {
if (k > p[i].cnt) {
k -= p[i].cnt;
book[p[i].a - 'a'] = 1;
}
else {
ans = 26 - i;
break;
}
}
printf("%d\n", ans);
if (ans) {
for (int i = 0; i < strlen(s); i++) {
if (book[s[i] - 'a'] == 1)continue;
else printf("%c", s[i]);
}
}
else printf("");
return 0;
}