#include <bits/stdc++.h>
using namespace std;
int check(char a[]) {
  int i;
  for (i = 0; a[i] != '\0'; i++)
    ;
  return i;
}
struct TMD {
  int m;
  char c;
} nnd[30];
int main() {
  char n[100020];
  int k;
  int test;
  int i, j, t;
  char str;
  short int sign[100020];
  int num;
  while (cin >> n >> test) {
    num = 0;
    memset(nnd, 0, sizeof(nnd));
    memset(sign, 0, sizeof(sign));
    int len = check(n);
    if (len <= test) {
      cout << "0" << endl;
      continue;
    }
    for (i = 0; i < len; i++) {
      (nnd[n[i] - 96].m)++;
      nnd[n[i] - 96].c = n[i];
    }
    for (i = 1; i <= 26; i++) {
      k = i;
      for (j = i + 1; j <= 26; j++) {
        if (nnd[j].m < nnd[k].m) k = j;
        if ((nnd[j].m == nnd[k].m) && (nnd[j].m != 0) && (nnd[j].c > nnd[k].c))
          k = j;
      }
      if (k != i) {
        t = nnd[i].m;
        nnd[i].m = nnd[k].m;
        nnd[k].m = t;
        str = nnd[i].c;
        nnd[i].c = nnd[k].c;
        nnd[k].c = str;
      }
    }
    for (i = 1; i <= 26; i++)
      if (nnd[i].m != 0)
        num++;
      else
        continue;
    int q = 1;
    int flag;
    int g = 0;
    while (test > 0) {
      if (nnd[q].m == 0) {
        g++;
        q++;
        continue;
      }
      if (test >= nnd[q].m) {
        flag = 1;
        test = test - nnd[q].m;
        for (i = 0; i < len; i++) {
          if (n[i] == nnd[q].c) sign[i] = 1;
        }
        if (test == 0) break;
      } else {
        flag = 0;
        break;
      }
      q++;
    }
    if (flag == 1)
      num -= (q - g);
    else
      num -= (q - g - 1);
    cout << num << endl;
    for (i = 0; i < len; i++)
      if (sign[i] == 0) cout << n[i];
    cout << endl;
  }
  return 0;
}
