#include <bits/stdc++.h>
using namespace std;
void prepare() {}
void solve() {
  string s;
  cin >> s;
  vector<pair<int, char> > v(26);
  for (int i = 0; i < (26); ++i) v[i].second = 'a' + i;
  for (int i = 0; i < ((int)(s).size()); ++i) v[s[i] - 'a'].first++;
  int n;
  cin >> n;
  sort((v).begin(), (v).end());
  int i = 0;
  while (i < 26 && n >= v[i].first) {
    if (v[i].first != 0) {
      n -= v[i].first;
      v[i].first = -1;
    }
    ++i;
  }
  for (i = 0; i < 26 && v[i].first < 1; ++i) {
    if (v[i].first == -1) {
      string st = "";
      char ch = v[i].second;
      for (int j = 0; j < ((int)(s).size()); ++j)
        if (s[j] != ch) st += s[j];
      s = st;
    }
  }
  cout << 26 - i << endl;
  cout << s;
}
int main() {
  prepare();
  solve();
  return 0;
}
