#include <bits/stdc++.h>
using namespace std;
char s[100010];
struct Node {
  int i, num;
} a[30];
bool cmp(Node a, Node b) { return a.num < b.num; }
int main() {
  scanf("%s", s);
  int n, k, flag[30] = {0};
  scanf("%d", &n);
  int l = strlen(s);
  for (int i = 0; i < l; i++) {
    a[s[i] - 'a'].i = s[i] - 'a';
    a[s[i] - 'a'].num++;
  }
  sort(a, a + 26, cmp);
  k = 0;
  for (int i = 0; i < 26; i++) {
    if (!a[i].num) continue;
    if (a[i].num <= n) {
      n -= a[i].num;
      flag[a[i].i] = a[i].num;
    } else {
      k = 26 - i;
      flag[a[i].i] = n;
      break;
    }
  }
  printf("%d\n", k);
  for (int i = 0; i < l; i++) {
    if (flag[s[i] - 'a'] > 0)
      flag[s[i] - 'a']--;
    else
      printf("%c", s[i]);
  }
  printf("\n");
  return 0;
}
