#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<pair<char, int> > mas;
  string s;
  int k;
  cin >> s >> k;
  vector<pair<int, int> > cnt(26);
  vector<char> fl(26);
  for (int i = 0; i < 26; i++) cnt[i].second = i;
  for (int i = 0; i < s.size(); i++) cnt[s[i] - 'a'].first++;
  sort(cnt.begin(), cnt.end());
  int sum = 0;
  for (int i = 0; i < 26; i++) {
    sum += cnt[i].first;
    if (sum <= k) fl[cnt[i].second] = true;
  }
  vector<char> fl2(26);
  string res;
  for (int i = 0; i < s.size(); i++) {
    if (fl[s[i] - 'a'] == false) {
      res.push_back(s[i]);
      fl2[s[i] - 'a'] = true;
    }
  }
  cout << count(fl2.begin(), fl2.end(), true);
  cout << "\n" << res;
  return 0;
}
