#include <bits/stdc++.h>
using namespace std;
int main() {
  char line[100001];
  int k;
  scanf("%s %d", line, &k);
  int ccount[256] = {0};
  for (int i = 0; line[i]; i++) ccount[line[i]]++;
  vector<pair<int, char> > rem;
  for (int i = 0; i < 256; i++)
    if (ccount[i]) rem.push_back(make_pair(ccount[i], i));
  sort(rem.begin(), rem.end());
  int c;
  for (c = 0; c < rem.size(); c++) {
    if (rem[c].first <= k) {
      k -= rem[c].first;
      ccount[rem[c].second] = 0;
    } else
      break;
  }
  printf("%d\n", rem.size() - c);
  for (int i = 0; line[i]; i++) {
    if (ccount[line[i]]) putchar(line[i]);
  }
  putchar('\n');
  return 0;
}
