#include <bits/stdc++.h>
using namespace std;
int t[30], t2[30];
int letter[30];
int main() {
  string s;
  int k;
  cin >> s >> k;
  if (k > s.length()) k = s.length();
  for (int i = 0; i < s.length(); i++) {
    t[s[i] - 'a']++;
    t2[s[i] - 'a']++;
  }
  for (int i = 0; i < 26; i++) letter[i] = i;
  for (int i = 0; i < 26; i++)
    for (int j = i + 1; j < 26; j++)
      if (t[j] < t[i]) {
        swap(t[j], t[i]);
        swap(letter[j], letter[i]);
      }
  int i = 0;
  while (i < 26 && k >= t2[letter[i]]) {
    k -= t2[letter[i]];
    t2[letter[i]] = 0;
    i++;
  }
  if (i < 26) t2[letter[i]] -= k;
  cout << 26 - i << endl;
  for (int i = 0; i < s.length(); i++) {
    if (t2[s[i] - 'a'] > 0) {
      cout << s[i];
      t2[s[i] - 'a']--;
    }
  }
  cout << endl;
  return 0;
}
