#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1e9;
int main() {
  vector<pair<int, int> > v(26, make_pair(INF, -1));
  vector<vector<int> > g(26);
  vector<int> w;
  int i, k, p = 0;
  string s;
  getline(cin, s);
  cin >> k;
  for (i = 0; i < s.size(); i++) {
    if (v[s[i] - 'a'].second == -1) {
      v[s[i] - 'a'].first = 0;
      v[s[i] - 'a'].second = s[i] - 'a';
      p++;
    }
    v[s[i] - 'a'].first++;
    g[s[i] - 'a'].push_back(i);
  }
  sort(v.begin(), v.begin() + 26);
  for (i = 0; i < 26; i++) {
    if (v[i].first != INF) {
      while (v[i].first && k) {
        w.push_back(g[v[i].second][g[v[i].second].size() - 1]);
        g[v[i].second].pop_back();
        v[i].first--;
        k--;
      }
      if (v[i].first == 0) p--;
      if (!k) break;
    } else
      break;
  }
  sort(w.begin(), w.end());
  for (i = 0; i < w.size(); i++) s.erase(w[i] - i, 1);
  printf("%d\n", p);
  printf("%s\n", s.c_str());
  return 0;
}
