#include <bits/stdc++.h>
using namespace std;
const int maxint = 999999999;
string s;
int cnt[30];
int k;
int main() {
  int i;
  while (cin >> s) {
    cin >> k;
    int l = s.length();
    if (l <= k) {
      printf("0\n");
      printf("\n");
      continue;
    }
    for (i = 0; i < l; i++) {
      cnt[s[i] - 'a']++;
    }
    int Min, u;
    while (1) {
      if (k == 0) break;
      Min = maxint;
      u = -1;
      for (i = 0; i < 26; i++) {
        if (cnt[i] > 0 && cnt[i] < Min) {
          Min = cnt[i];
          u = i;
        }
      }
      if (Min > k) {
        k = 0;
        cnt[u] -= k;
      } else {
        cnt[u] = 0;
        k -= Min;
      }
    }
    int ans = 0;
    for (i = 0; i < 26; i++) {
      if (cnt[i] > 0) ans++;
    }
    printf("%d\n", ans);
    for (i = 0; i < l; i++) {
      if (cnt[s[i] - 'a'] > 0) printf("%c", s[i]);
    }
    printf("\n");
  }
  return 0;
}
