#include <bits/stdc++.h>
using namespace std;
pair<int, int> p[26];
string str;
int main() {
  int k, unique = 0;
  cin >> str;
  cin >> k;
  int len = str.length();
  for (int i = 0; i < len; i++) {
    if (!p[str[i] - 'a'].first) unique++;
    p[str[i] - 'a'].first++;
    p[str[i] - 'a'].second = str[i];
  }
  sort(p, p + 26);
  for (int i = 0; i < 26; i++) {
    if (p[i].first && p[i].first <= k) {
      k -= p[i].first;
      unique--;
      for (int j = 0; j < len; j++)
        if (str[j] == p[i].second) str[j] = ' ';
    }
  }
  cout << unique << endl;
  for (int i = 0; i < len; i++) {
    if (str[i] != ' ') cout << str[i];
  }
  return 0;
}
