#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
int main() {
  string s;
  int n;
  cin >> s >> n;
  if (n >= s.length()) {
    cout << "0";
    return 0;
  }
  vector<pair<int, char> > v;
  for (int i = (0); i < (s.length()); ++i) {
    bool loc = 1;
    for (int j = (0); j < (v.size()); ++j)
      if (v[j].second == s[i]) {
        loc = 0;
        ++v[j].first;
        break;
      }
    if (loc) v.push_back(make_pair(1, s[i]));
  }
  sort(v.begin(), v.end());
  vector<char> del;
  int j = 0;
  while ((n - v[j].first) >= 0) {
    del.push_back(v[j].second);
    n -= v[j].first;
    ++j;
  }
  cout << v.size() - j << endl;
  j = 0;
  while (j < s.length()) {
    bool loc = 1;
    for (int i = (0); i < (del.size()); ++i)
      if (del[i] == s[j]) {
        s.erase(j, 1);
        loc = 0;
        break;
      }
    if (loc) ++j;
  }
  cout << s;
  return 0;
}
