#include <bits/stdc++.h>
using namespace std;
int main() {
  char s[100010];
  scanf("%s", s);
  int k;
  scanf("%d", &k);
  pair<int, char> v[26];
  for (int i = 0; i < 26; i++) {
    v[i].second = 'a' + i;
    v[i].first = 0;
  }
  int q = 0;
  for (int i = 0; s[i]; i++) {
    if (v[s[i] - 'a'].first == 0) q++;
    v[s[i] - 'a'].first++;
  }
  sort(v, v + 26);
  int j = 0;
  while (v[j].first == 0) j++;
  int l = j;
  while (k >= v[l].first && l < 26) {
    k -= v[l].first;
    l++;
    q--;
  }
  printf("%d\n", q);
  for (int a = 0; s[a]; a++) {
    int b = j;
    for (; b < l; b++)
      if (s[a] == v[b].second) break;
    if (b == l) printf("%c", s[a]);
  }
  printf("\n");
  return 0;
}
