#include <bits/stdc++.h>
using namespace std;
int main() {
  int v[123];
  memset(v, 0, sizeof(int) * 123);
  string cad;
  int n;
  cin >> cad >> n;
  for (int i = 0; i < cad.size(); ++i) {
    int r = cad[i];
    v[r]++;
  }
  while (n > 0) {
    int min = 999999, j = 0;
    for (int i = 97; i < 123; ++i) {
      if (v[i] < min && v[i] != 0) {
        min = v[i];
        j = i;
      }
    }
    n = n - min;
    if (n >= 0) {
      v[j] = 0;
    }
  }
  int pd = 0;
  for (int i = 97; i < 123; ++i) {
    if (v[i] != 0) pd++;
  }
  printf("%d\n", pd);
  for (int i = 0; i < cad.size(); ++i) {
    int y = cad[i];
    if (v[y] != 0) printf("%c", cad[i]);
  }
  return 0;
}
