#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  int c[26];
  int k, i, count, min, j;
  while (cin >> str >> k) {
    if (k > str.length()) {
      cout << 0 << endl;
      cout << endl;
    } else {
      memset(c, 0, sizeof(c));
      count = 0;
      for (i = 0; i < str.length(); ++i) {
        c[str[i] - 'a']++;
        if (c[str[i] - 'a'] == 1) count++;
      }
      min = 100005;
      while (k > 0) {
        for (i = 0; i < 26; ++i) {
          if (c[i] > 0) {
            if (c[i] < min) {
              min = c[i];
              j = i;
            }
          }
        }
        if (min > k) break;
        k -= min;
        min = 100005;
        c[j] = -1;
        count--;
      }
      cout << count << endl;
      for (i = 0; i < str.length(); ++i) {
        if (c[str[i] - 'a'] == -1) continue;
        printf("%c", str[i]);
      }
      cout << endl;
    }
  }
  return 0;
}
