#include <bits/stdc++.h>
using namespace std;
char ch[100008];
int cnt[30];
int main() {
  int k;
  scanf("%s", ch);
  cin >> k;
  int len = strlen(ch);
  if (k >= len) {
    cout << 0 << endl;
    puts("");
    return 0;
  }
  for (int i = 0; i < len; i++) {
    cnt[ch[i] - 'a' + 1]++;
  }
  while (1) {
    int min = 2000000;
    int index = -1;
    for (int i = 1; i <= 26; i++) {
      if (cnt[i] != 0 && cnt[i] < min) {
        min = cnt[i];
        index = i;
      }
    }
    if (k >= min) {
      k -= min;
      cnt[index] = 0;
    } else
      break;
  }
  int x = 0;
  for (int i = 1; i <= 26; i++) {
    if (cnt[i]) x++;
  }
  cout << x << endl;
  for (int i = 0; i < len; i++) {
    if (cnt[ch[i] - 'a' + 1]) cout << ch[i];
  }
  cout << endl;
}
