#include <bits/stdc++.h>
using namespace std;
vector<pair<int, char> > v;
int a[26], fin[26];
int main() {
  int k;
  string s;
  cin >> s;
  scanf("%d", &k);
  ;
  if (k >= s.size()) {
    printf("0\n");
    exit(0);
  }
  for (int i = 0; i < s.size(); i++) {
    a[s[i] - 97]++;
  }
  for (int i = 0; i < 26; i++) {
    v.push_back(make_pair(a[i], i + 97));
  }
  sort(v.begin(), v.end());
  ;
  int cnt = 26;
  for (int i = 0; i < 26; i++) {
    if (k < v[i].first)
      break;
    else {
      k -= v[i].first;
      fin[v[i].second - 97] = 1;
    }
    cnt--;
  }
  printf("%d\n", cnt);
  for (int i = 0; i < s.size(); i++) {
    if (fin[s[i] - 97] != 1) cout << s[i];
  }
  printf("\n");
  ;
  return 0;
}
