#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  char s[100005] = {0};
  int i, j;
  int panjang;
  int banyak[27] = {0};
  gets(s);
  scanf("%d", &n);
  panjang = strlen(s);
  if (panjang <= n) {
    printf("0\n");
    return 0;
  }
  for (i = 0; i < panjang; i++) {
    ++banyak[s[i] - 'a'];
  }
  int hasil = 0;
  for (i = 0; i < 26; i++)
    if (banyak[i] > 0) ++hasil;
  int min = 100005;
  int indeks;
  while (1) {
    min = 100005;
    for (i = 0; i < 26; i++) {
      if (banyak[i] > 0 && banyak[i] < min) {
        min = banyak[i];
        indeks = i;
      }
    }
    if (banyak[indeks] > n) break;
    --hasil;
    n -= banyak[indeks];
    banyak[indeks] = 0;
  }
  printf("%d\n", hasil);
  for (i = 0; i < panjang; i++) {
    if (banyak[s[i] - 'a'] > 0) printf("%c", s[i]);
  }
  return 0;
}
