#include <bits/stdc++.h>
using namespace std;
pair<int, int> a[26];
int b[26];
int main() {
  for (int i = 0; i < 26; i++) a[i].second = i;
  string s;
  cin >> s;
  int d;
  cin >> d;
  for (int i = 0; i < int(s.size()); i++) a[int(s[i] - 'a')].first++;
  sort(a, a + 26);
  int tmp = 0;
  for (int i = 0; i < 26; i++)
    if (d >= a[i].first) {
      b[tmp] = a[i].second;
      tmp++;
      d -= a[i].first;
    }
  bool g;
  cout << 26 - tmp << endl;
  for (int i = 0; i < int(s.size()); i++) {
    g = 1;
    for (int j = 0; j < tmp; j++)
      if (int(s[i] - 'a') == b[j]) g = 0;
    if (g) cout << s[i];
  }
  return 0;
}
