#include <bits/stdc++.h>
using namespace std;
string s, ans;
int occ[30], k, diff;
vector<pair<int, int> > temp;
int main(void) {
  cin >> s >> k;
  memset(occ, 0, sizeof(occ));
  for (int i = 0; i < s.length(); i++) occ[s[i] - 'a']++;
  for (int i = 0; i < 30; i++) {
    if (occ[i] > 0) temp.push_back(make_pair(occ[i], i));
  }
  sort(temp.begin(), temp.end());
  for (int i = 0; i < temp.size(); i++) {
    if (k == 0) break;
    if (temp[i].first <= k) {
      occ[temp[i].second] = 0;
      k -= temp[i].first;
    } else {
      occ[temp[i].second] -= k;
      k = 0;
    }
  }
  ans = "";
  diff = 0;
  for (int i = 0; i < 30; i++)
    if (occ[i] > 0) diff++;
  for (int i = 0; i < s.length(); i++) {
    if (occ[s[i] - 'a'] > 0) {
      ans += s[i];
      occ[s[i] - 'a']--;
    }
  }
  cout << diff << endl << ans << endl;
}
