#include <bits/stdc++.h>
using namespace std;
pair<int, int> F[26];
int main() {
  string s;
  int k;
  cin >> s >> k;
  int siz = s.size();
  for (int i = 0; i < siz; i++) {
    F[s[i] - 'a'].first++;
  }
  for (int i = 0; i < 26; i++) F[i].second = i;
  sort(F, F + 26);
  int id = 0;
  while (id < 26 && k >= F[id].first) {
    k -= F[id].first;
    F[id].first = 0;
    id++;
  }
  int rem = 0;
  for (int i = 0; i < 26; i++) rem += (bool)F[i].first;
  cout << rem << endl;
  for (int i = 0; i < 26; i++) swap(F[i].first, F[i].second);
  sort(F, F + 26);
  for (int i = 0; i < siz; i++)
    if (F[s[i] - 'a'].second) cout << s[i];
  return 0;
}
