#include <bits/stdc++.h>
struct T {
  int a, b;
};
int compare(const void* a, const void* b) { return ((T*)a)->a - ((T*)b)->a; }
int main() {
  int n, k;
  char mystr[100001], ans[100001];
  T ch[26];
  int take, tmp;
  scanf("%s%d", mystr, &k);
  n = strlen(mystr);
  if (k >= n) {
    printf("0\n");
    return 0;
  }
  for (int i = 0; i < 26; i++) ch[i].a = 0, ch[i].b = i;
  for (int i = 0; i < n; i++) ch[mystr[i] - 'a'].a++;
  qsort(ch, 26, sizeof(T), compare);
  tmp = n;
  for (take = 25; take >= 0; take--) {
    if (tmp - ch[take].a <= k) break;
    tmp -= ch[take].a;
  }
  int j = 0;
  for (int i = 0; i < n; i++) {
    for (int k = take; k < 26; k++) {
      if (mystr[i] - 'a' == ch[k].b) {
        ans[j++] = mystr[i];
        break;
      }
    }
  }
  ans[j] = 0;
  printf("%d\n%s\n", 26 - take, ans);
  return 0;
}
