#include <bits/stdc++.h>
using namespace std;
char str[100005];
int n;
int len;
int chac[26];
int main() {
  int i, j;
  int coun = 0;
  char c;
  scanf("%s", str);
  scanf("%d", &n);
  len = strlen(str);
  if (len <= n) {
    printf("0\n");
  } else {
    for (i = 0; i < len; i++) {
      chac[str[i] - 'a']++;
    }
    while (true) {
      int mini = 100005;
      int index = 0;
      for (i = 0; i < 26; i++) {
        if (chac[i] < mini && chac[i] != 0) {
          mini = chac[i];
          index = i;
        }
      }
      c = 'a' + index;
      if (chac[index] > n - coun) break;
      int st = 0;
      for (i = 0; i < len; i++) {
        if (str[i] == c) {
          coun++;
          st++;
          str[i] = '-';
        }
        if (coun == n) break;
      }
      if (coun == n) {
        if (st == chac[index]) chac[index] = 0;
        break;
      } else {
        chac[index] = 0;
      }
    }
    int sum = 0;
    for (i = 0; i < 26; i++) {
      if (chac[i] != 0) sum++;
    }
    printf("%d\n", sum);
    for (i = 0; i < len; i++) {
      if (str[i] != '-') printf("%c", str[i]);
    }
  }
  return 0;
}
