#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  int count = 0, different = 0, min, min_index, i, m, l = str.length(), a[100];
  cin >> str;
  cin >> m;
  l = str.length();
  for (i = 0; i < 26; ++i) {
    a[i] = 0;
  }
  for (i = 0; i < l; ++i) {
    if ((int)a[str[i] - 97] == 0) ++different;
    a[(int)str[i] - 97]++;
  }
  while (m > 0) {
    min = 999999;
    for (i = 0; i < 26; ++i) {
      if (a[i] < min && a[i] > 0) {
        min = a[i];
        min_index = i;
      }
    }
    m -= min;
    char x;
    a[min_index] = 0;
    if (m >= 0) {
      x = (char)(min_index + 97);
      string::iterator it = remove(str.begin(), str.end(), x);
      str.erase(it, str.end());
      ++count;
    }
  }
  cout << different - count << endl;
  cout << str;
  return 0;
}
