#include <bits/stdc++.h>
using namespace std;
int a[1000], b[1000];
int main() {
  string s;
  int kk, i;
  getline(cin, s);
  cin >> kk;
  memset(a, 0, sizeof(a));
  memset(b, 0, sizeof(b));
  for (i = 0; i < s.length(); i++) a[s[i] - 'a' + 1]++;
  int cur = 0, res = 26;
  while (true) {
    int k = (1000000000), p = -1;
    for (i = 1; i <= 26; i++)
      if (b[i] == 0 && k > a[i]) {
        k = a[i];
        p = i;
      }
    if (p == -1) {
      res = 0;
      break;
    }
    b[p] = 1;
    cur += a[p];
    res--;
    if (cur > kk) {
      cur -= a[p];
      b[p] = 0;
      res++;
      break;
    }
  }
  cerr << endl;
  cout << res << endl;
  for (i = 0; i < s.length(); i++)
    if (b[s[i] - 'a' + 1] == 0) cout << s[i];
  cout << endl;
}
