#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int i, r, ans, k, cnt, a[30];
  bool b[30], f;
  memset(a, 0, sizeof(a));
  memset(b, 0, sizeof(b));
  cin >> s;
  cin >> k;
  cnt = r = 0;
  for (i = 0; i < s.size(); ++i) {
    if (a[s[i] - 'a'] == 0) ++cnt;
    ++a[s[i] - 'a'];
  }
  f = true;
  a[26] = 1000 * 1000;
  while (f) {
    f = false;
    ans = 26;
    for (i = 0; i < 26; ++i)
      if (!b[i] && a[i] > 0 && a[i] < a[ans] && a[i] <= k) {
        ans = i;
        f = true;
      }
    if (f) {
      ++r;
      b[ans] = true;
      k -= a[ans];
    }
  }
  cout << cnt - r << endl;
  for (i = 0; i < s.size(); ++i)
    if (!b[s[i] - 'a']) cout << s[i];
  cout << endl;
  return 0;
}
