#include <bits/stdc++.h>
bool tham[10000];
long a[10000], b[10000];
char d[10000], s[100001];
using namespace std;
int main() {
  long tg, n, i, dem, j, u;
  char c;
  scanf("%s", &s);
  scanf("%ld", &n);
  u = strlen(s);
  for (i = 0; i < 9999; i++) a[i] = 0;
  for (i = 0; i < u; i++) a[s[i]] = a[s[i]] + 1;
  dem = 0;
  for (c = 'a'; c <= 'z'; c++)
    if (a[c] != 0) {
      dem++;
      d[dem] = c;
      b[dem] = a[c];
    }
  for (i = 1; i <= dem - 1; i++)
    for (j = i + 1; j <= dem; j++)
      if (b[i] > b[j]) {
        tg = b[i];
        b[i] = b[j];
        b[j] = tg;
        c = d[i];
        d[i] = d[j];
        d[j] = c;
      }
  long t, di;
  t = n;
  di = 0;
  for (c = 'a'; c <= 'z'; c++) tham[c] = false;
  for (i = 1; i <= dem; i++) {
    if (t >= b[i])
      t = t - b[i];
    else
      break;
    tham[d[i]] = true;
    di++;
  }
  cout << dem - di << "\n";
  for (i = 0; i < u; i++)
    if (tham[s[i]] == false) printf("%c", s[i]);
}
