#include <bits/stdc++.h>
using namespace std;
int main() {
  char str[100004];
  int k, h[26] = {0}, i;
  cin >> str;
  cin >> k;
  i = 0;
  while (str[i]) {
    h[str[i] - 'a']++;
    i++;
  }
  if (i <= k) {
    cout << "0";
    return 0;
  } else if (k == 0) {
    for (i = 0, k = 0; i < 26; i++) {
      if (h[i] > 0) k++;
    }
    cout << k << endl;
    cout << str;
    return 0;
  }
  while (k > 0) {
    int j = 0, max = 100003;
    for (i = 0; i < 26; i++)
      if (max >= h[i] && h[i] != 0) {
        max = h[i];
        j = i;
      }
    if (h[j] >= k) {
      h[j] -= k;
      k = 0;
    } else {
      k -= h[j];
      h[j] = 0;
    }
  }
  for (i = 0, k = 0; i < 26; i++) {
    if (h[i] > 0) k++;
  }
  cout << k << endl;
  for (i = 0; str[i]; i++)
    if (h[str[i] - 'a'] > 0) {
      cout << str[i];
      h[str[i] - 'a']--;
    }
  return 0;
}
