#include <bits/stdc++.h>
using namespace std;
int main() {
  string w;
  long long count = 0;
  long long n, k;
  pair<long long, char> amount[100005];
  cin >> w;
  cin >> k;
  map<char, int> le;
  n = w.size();
  if (k >= n) {
    cout << 0;
    return 0;
  }
  for (int i = 0; i < n; i++) {
    if (le.count(w[i]) == 0) {
      le[w[i]] = count;
      amount[count] = make_pair(1, w[i]);
      count++;
    } else {
      int temp = le[w[i]];
      amount[temp].first++;
    }
  }
  sort(amount, amount + count);
  long long away = amount[0].first;
  set<char> salen;
  int t = 1;
  if (away > k) {
    cout << count << endl;
    cout << w;
    return 0;
  } else {
    salen.insert(amount[0].second);
    if (amount[1].first >= 1) away += amount[1].first;
    while (away <= k) {
      salen.insert(amount[t].second);
      t++;
      if (amount[t].first >= 1)
        away += amount[t].first;
      else
        break;
    }
  }
  cout << count - t << endl;
  for (int i = 0; i < n; i++) {
    if (salen.count(w[i]) != 0)
      continue;
    else
      cout << w[i];
  }
}
