#include <bits/stdc++.h>
using namespace std;
int main(int argc, char** argv) {
  if (argc > 1) freopen(argv[1], "r", stdin);
  string s;
  getline(cin, s);
  vector<pair<int, int> > a(26);
  for (int i = 0; i < (26); ++i) a[i].second = i;
  for (int i = 0; i < (((int)((s).size()))); ++i) ++a[s[i] - 'a'].first;
  int k;
  scanf("%d", &k);
  sort((a).begin(), (a).end());
  int num = 0;
  bool d[26] = {0};
  for (int i = 0; i < (26); ++i)
    if (k - a[i].first >= 0) ++num, d[a[i].second] = 1, k -= a[i].first;
  string t;
  for (int i = 0; i < (((int)((s).size()))); ++i)
    if (!d[s[i] - 'a']) t += s[i];
  printf("%d\n%s\n", 26 - num, t.c_str());
  return 0;
}
