#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > vec;
int tedad[30], del[30];
bool mark[30];
int main() {
  string s;
  int k;
  cin >> s >> k;
  for (int i = 0; i < s.length(); i++) tedad[s[i] - 'a']++;
  for (int i = 0; i < 26; i++) vec.push_back(make_pair(tedad[i], i));
  sort(vec.begin(), vec.end());
  for (int j = 0; j < 26; j++) {
    int i = vec[j].second;
    while (tedad[i] != 0 && k) {
      tedad[i]--;
      k--;
      del[i]++;
    }
  }
  string ans = "";
  int t = 0;
  for (int i = 0; i < s.length(); i++)
    if (del[s[i] - 'a'] > 0)
      del[s[i] - 'a']--;
    else {
      if (!mark[s[i] - 'a']) {
        t++;
        mark[s[i] - 'a'] = true;
      }
      ans += s[i];
    }
  cout << t << endl << ans << endl;
}
