#include <bits/stdc++.h>
using namespace std;
long per[1000000], c[26], d[26], fix[100];
long p, cur, ans, j, x, n, k, i;
int main() {
  string s;
  cin >> s;
  n = s.size();
  scanf("%d", &k);
  if (k >= n)
    printf("0\n");
  else {
    for (i = 0; i < n; i++) {
      c[s[i] - 'a']++;
      d[s[i] - 'a']++;
    }
    sort(c, c + 26);
    x = 0;
    while (c[x] == 0) x++;
    cur = 26 - x;
    while (k >= c[x]) {
      k = k - c[x];
      for (i = 0; i < 26; i++)
        if (d[i] == c[x] && fix[i] == 0) {
          fix[i] = 1;
          for (j = 0; j < n; j++)
            if (s[j] - 'a' == i) per[j]++;
          break;
        }
      x++;
    }
    ans = 26 - x;
    printf("%d\n", ans);
    for (i = 0; i < n; i++)
      if (per[i] == 0) printf("%c", s[i]);
  }
}
