#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  cin >> str;
  long long n;
  cin >> n;
  while (((long long)str.size())) {
    char c = str[0];
    for (long long i = 0; i < ((long long)26); i++) {
      long long ta = count(str.begin(), str.end(), c);
      long long tb = count(str.begin(), str.end(), i + 'a');
      if (tb && tb < ta) c = i + 'a';
    }
    if (n < count(str.begin(), str.end(), c)) break;
    n -= count(str.begin(), str.end(), c);
    string s = "";
    for (long long i = 0; i < ((long long)((long long)str.size())); i++)
      if (str[i] != c) s += str[i];
    str = s;
  }
  long long res = 0;
  for (long long i = 0; i < ((long long)26); i++)
    if (count(str.begin(), str.end(), i + 'a')) res++;
  cout << res << endl << str << endl;
}
