#include <bits/stdc++.h>
using namespace std;
int cnt[26];
int main() {
  memset(cnt, 0, sizeof(cnt));
  string s;
  int k;
  getline(cin, s);
  cin >> k;
  for (int i = 0; i < s.length(); i++) cnt[s[i] - 'a']++;
  vector<pair<int, char> > cnts;
  for (int i = 0; i < 26; i++) {
    if (cnt[i] > 0) cnts.push_back(make_pair(cnt[i], i + 'a'));
  }
  sort(cnts.begin(), cnts.end());
  int i = 0;
  int remain = cnts.size();
  while (i < cnts.size() && k >= cnts[i].first) {
    k -= cnts[i].first;
    remain--;
    cnt[cnts[i].second - 'a'] = 0;
    i++;
  }
  cout << remain << endl;
  for (int i = 0; i < s.length(); i++) {
    if (cnt[s[i] - 'a'] > 0) cout << s[i];
  }
  cout << endl;
}
