#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int n;
  cin >> n;
  int cnt[26];
  memset(cnt, 0, sizeof(cnt));
  for (auto c : s) {
    ++cnt[c - 'a'];
  }
  while (n > 0) {
    int mn = -1, pos = -1;
    for (int i = 0; i < 26; ++i) {
      if (cnt[i] <= 0) {
        continue;
      }
      if (mn == -1 || mn > cnt[i]) {
        mn = cnt[i];
        pos = i;
      }
    }
    if (mn < 0 || n < mn) {
      break;
    }
    n -= cnt[pos];
    cnt[pos] = 0;
  }
  int m = 0;
  for (int i = 0; i < 26; ++i) {
    if (cnt[i] > 0) {
      ++m;
    }
  }
  cout << m << endl;
  for (auto c : s) {
    if (cnt[c - 'a'] > 0) {
      cout << c;
    }
  }
  cout << endl;
  return 0;
}
