#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:100000000")
char s[100500];
int a[50], ind[50];
bool use[50];
bool cmp(int i, int j) { return a[i] < a[j]; }
int main() {
  int i, j;
  gets(s);
  int k;
  int l = strlen(s);
  for (i = 0; i < l; ++i) a[s[i] - 'a']++;
  scanf("%d", &k);
  for (i = 0; i < 26; ++i) ind[i] = i;
  sort(ind, ind + 26, cmp);
  int sum = 0;
  for (i = 0; i < 26 && sum + a[ind[i]] <= k; ++i) sum += a[ind[i]];
  int ans = 0;
  for (j = i; j < 26; ++j)
    if (a[ind[j]] > 0) {
      ++ans;
      use[ind[j]] = true;
    }
  printf("%d\n", ans);
  for (i = 0; i < l; ++i)
    if (use[s[i] - 'a']) printf("%c", s[i]);
  return 0;
}
