#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<pair<int, char> > v(26);
  for (int i = 0; i < 26; i++) v[i].second = ('a' + i);
  string s;
  int n;
  cin >> s >> n;
  for (int i = 0; i < s.length(); i++) v[s[i] - 'a'].first++;
  sort(v.begin(), v.end());
  for (int i = 0; i < 26; i++) {
    if (v[i].first == 0) continue;
    n -= v[i].first;
    if (n < 0) break;
    v[i].first = 0;
    for (int j = 0; j < s.length(); j++) {
      if (s[j] == v[i].second) s.erase(j, 1), j--;
    }
  }
  int counter = 0;
  for (int i = 0; i < 26; i++)
    if (v[i].first != 0) counter++;
  cout << counter << endl << s << endl;
  return 0;
}
