#include <bits/stdc++.h>
using namespace std;
struct punct {
  long long x, y;
} a[100010];
int compare(punct a, punct b) {
  if (a.y == b.y)
    return a.x < b.x;
  else
    return a.y < b.y;
}
long long n, k, i, x, nr, cp, sm, j, nr2;
char s[100010], ch;
int main() {
  scanf("%s %lld", &s, &k);
  n = strlen(s);
  {
    for (i = 0; i < n; i++) {
      x = s[i] - 'a' + 1;
      if (a[x].y == 0) {
        nr++;
        a[x].x = x;
        a[x].y++;
      } else
        a[x].y++;
    }
    sort(a + 1, a + 27, compare);
    cp = k;
    for (i = 1; i <= 26; i++) {
      if (a[i].y != 0 && cp - a[i].y >= 0) {
        nr2++;
        cp = cp - a[i].y;
        a[i].y = (-1);
      }
    }
    printf("%lld\n", nr - nr2);
    if (nr - nr2 > 0) {
      for (i = 0; i < n; i++) {
        x = s[i] - 'a' + 1;
        ch = s[i];
        for (j = 1; j <= 27; j++)
          if (a[j].y != -1 && a[j].x == x) {
            printf("%c", ch);
            break;
          }
      }
    }
  }
  return 0;
}
