#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  getline(cin, s);
  int n;
  cin >> n;
  int p = s.size();
  vector<pair<int, int> > d(26, make_pair(0, 0));
  for (int i = 0; i < 26; i++) d[i].second = i;
  for (int i = 0; i < s.size(); i++) d[s[i] - 'a'].first++;
  sort(d.begin(), d.end());
  vector<int> t(26, 1);
  for (int i = 0; i <= 26; i++)
    if (i == 26) {
      cout << 0 << endl << endl;
    } else if (p - d[i].first >= int(s.size()) - n) {
      p -= d[i].first;
      t[d[i].second] = 0;
    } else {
      if (i == 26)
        cout << 0 << endl << endl;
      else {
        cout << 26 - i << endl;
        for (int j = 0; j < s.size(); j++)
          if (t[s[j] - 'a']) printf("%c", s[j]);
      }
      cout << endl;
      break;
    }
}
