#include <bits/stdc++.h>
using namespace std;
char c[100005], b[100005];
int a[26];
int main() {
  int n, k;
  scanf("%s%d", &c, &k);
  n = strlen(c);
  strcpy(b, c);
  int i;
  for (i = 0; c[i]; i++) a[c[i] - 'a']++;
  int st;
  int hi = 100005;
  for (st = 1; st <= 26; st++) {
    int cur = hi;
    int ch;
    for (i = 0; i < 26; i++)
      if (a[i] && a[i] < cur) {
        cur = a[i];
        ch = i;
      }
    if (cur < hi) {
      if (cur <= k) {
        k -= cur;
        a[ch] = 0;
      }
    }
  }
  int m = 0;
  for (i = 0; i < 26; i++)
    if (a[i]) m++;
  printf("%d\n", m);
  for (i = 0; c[i]; i++) {
    if (a[c[i] - 'a']) {
      printf("%c", c[i]);
      a[c[i] - 'a']--;
    }
  }
  return 0;
}
