#include <bits/stdc++.h>
using namespace std;
bool mark[26], flag[26];
struct letter {
  int num, id;
} l[26];
bool cmp(letter a, letter b) { return a.num < b.num; }
int main() {
  int k, i, len, co;
  string s, ans;
  while (cin >> s) {
    memset(mark, 0, sizeof(mark));
    memset(flag, 0, sizeof(flag));
    cin >> k;
    len = s.size();
    for (i = 0; i < 26; i++) {
      l[i].id = i;
      l[i].num = 0;
    }
    for (i = 0; i < len; i++) l[s[i] - 'a'].num++;
    sort(l, l + 26, cmp);
    i = 0;
    while (k >= l[i].num) {
      k -= l[i].num;
      mark[l[i].id] = 1;
      i++;
    }
    ans = "";
    co = 0;
    for (i = 0; i < len; i++)
      if (!mark[s[i] - 'a']) {
        ans += s[i];
        if (!flag[s[i] - 'a']) {
          flag[s[i] - 'a'] = 1;
          co++;
        }
      }
    cout << co << endl;
    if (co != 0) cout << ans << endl;
  }
  return 0;
}
