#include <bits/stdc++.h>
using namespace std;
int n, pol2[26];
struct doc {
  int c;
  char ch;
} pol[26];
int cmp(const void *a, const void *b) { return (*(doc *)a).c - (*(doc *)b).c; }
char s[100002];
int main() {
  int i, j, p;
  while (scanf("%s%d", s, &n) != EOF) {
    memset(pol, 0, sizeof(pol));
    for (i = 0; s[i] != '\0'; i++) {
      pol[s[i] - 'a'].c++;
      pol[s[i] - 'a'].ch = s[i];
      pol2[s[i] - 'a']++;
    }
    qsort(pol, 26, sizeof(pol[0]), cmp);
    for (i = 0; pol[i].c == 0; i++)
      ;
    for (; i <= 25; i++) {
      if (n - pol[i].c >= 0) {
        n -= pol[i].c;
        pol2[pol[i].ch - 'a'] = 0;
      } else
        break;
    }
    printf("%d\n", 26 - i);
    for (p = 0, j = 0; s[j] != '\0'; j++) {
      if (pol2[s[j] - 'a'] != 0) printf("%c", s[j]);
    }
    if (26 - i != 0) printf("\n");
  }
  return 0;
}
