#include <bits/stdc++.h>
typedef struct val {
  int index, count;
} a;
a arr[26];
char s[100000];
typedef int (*compfn)(const void *, const void *);
int compare(struct val *elem1, struct val *elem2) {
  if (elem1->count < elem2->count)
    return -1;
  else if (elem1->count > elem2->count)
    return 1;
  else
    return 0;
}
int comparei(struct val *elem1, struct val *elem2) {
  if (elem1->index < elem2->index)
    return -1;
  else if (elem1->index > elem2->index)
    return 1;
  else
    return 0;
}
int main() {
  int i, j, k;
  char c;
  for (i = 0; i < 26; i++) {
    arr[i].index = i;
    arr[i].count = 0;
  }
  gets(s);
  j = strlen(s);
  for (i = 0; i < j; i++) {
    arr[s[i] - 'a'].count++;
  }
  scanf("%d", &i);
  qsort(arr, 26, sizeof(a), (compfn)compare);
  j = 0;
  while (i != 0) {
    if (arr[j].count == 0) j++;
    if (j == 26)
      break;
    else if (arr[j].count <= i) {
      i -= arr[j].count;
      arr[j].count = 0;
    } else {
      arr[j].count -= i;
      i = 0;
    }
  }
  k = 0;
  for (i = 0; i < 26; i++) {
    if (arr[i].count > 0) k++;
  }
  printf("%d\n", k);
  qsort(arr, 26, sizeof(a), (compfn)comparei);
  j = strlen(s);
  for (i = 0; i < j; i++) {
    if (arr[s[i] - 'a'].count > 0) {
      printf("%c", s[i]);
      arr[s[i] - 'a'].count--;
    }
  }
  printf("\n");
  return 0;
}
