#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
struct node {
  int cnt;
  int pos;
} md[maxn];
int num[26];
char s[maxn];
int k;
int cmp(node a, node b) { return a.cnt < b.cnt; }
int main() {
  scanf("%s", s);
  scanf("%d", &k);
  int len = strlen(s);
  memset(num, 0, sizeof(num));
  for (int i = 0; i < len; i++) {
    num[s[i] - 'a']++;
  }
  for (int i = 0; i < 26; i++) {
    md[i].pos = i;
    md[i].cnt = num[i];
  }
  sort(md, md + 26, cmp);
  if (len <= k) {
    printf("0\n");
    return 0;
  }
  int cnt = 0;
  for (int i = 0; i < 26; i++) {
    if (md[i].cnt != 0 && k >= md[i].cnt) {
      k -= md[i].cnt;
      md[i].cnt = 0;
    }
  }
  for (int i = 0; i < 26; i++) {
    if (md[i].cnt != 0) {
      cnt++;
    }
  }
  printf("%d\n", cnt);
  for (int i = 0; i < len; i++) {
    for (int j = 0; j < 26; j++) {
      if (s[i] - 'a' == md[j].pos) {
        if (md[j].cnt != 0) {
          printf("%c", s[i]);
          break;
        } else
          break;
      }
    }
  }
  printf("\n");
}
