#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, i, j, ans = 0;
  set<char> s;
  char ch;
  string str;
  cin >> str >> k;
  for (i = 0; i < str.length(); i++) s.insert(str[i]);
  pair<int, int> a[27];
  for (i = 1; i <= 26; i++) {
    a[i].first = 100000000;
    a[i].second = i;
  }
  for (i = 0; i < str.length(); i++) {
    if (a[int(str[i]) - 96].first == 100000000) {
      a[int(str[i]) - 96].first = 0;
      a[int(str[i]) - 96].first++;
    } else
      a[int(str[i]) - 96].first++;
  }
  sort(a, a + 27);
  for (i = 1; i <= 26; i++) {
    if (a[i].first != 100000000 && k - a[i].first >= 0) {
      ans++;
      k -= a[i].first;
      a[i].first = 0;
    } else
      break;
  }
  cout << s.size() - ans << endl;
  for (i = 0; i < str.length(); i++) {
    ch = str[i];
    for (j = 1; j <= 26; j++) {
      if (a[j].second == int(ch) - 96) {
        if (a[j].first != 0)
          cout << ch;
        else
          break;
      }
    }
  }
  return 0;
}
