#include <bits/stdc++.h>
using namespace std;
int ABS(int _x) { return _x > 0 ? _x : -_x; }
int main() {
  int t[27] = {0}, N, K, res = 0;
  string s;
  cin >> s >> K;
  N = s.size();
  for (int(i) = (0); (i) < (N); (i)++) t[s[i] - 'a']++;
  vector<pair<int, int> > a;
  for (int(i) = (0); (i) < (26); (i)++)
    if (t[i] > 0) a.push_back(make_pair(t[i], i));
  sort(a.begin(), a.end());
  for (int(i) = (0); (i) < (a.size()); (i)++) {
    if (K <= 0) break;
    int x = min(a[i].first, K);
    K -= x;
    a[i].first -= x;
  }
  memset((t), 0, sizeof(t));
  for (int(i) = (0); (i) < (a.size()); (i)++)
    if (a[i].first > 0) {
      t[a[i].second] = a[i].first;
      res++;
    }
  cout << res << endl;
  for (int(i) = (0); (i) < (N); (i)++)
    if (t[s[i] - 'a']) {
      cout << s[i];
    }
  cout << endl;
  return 0;
}
