#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, k, n, na, nb, k1, k2, temp, p, q, flag = 0, x, y;
  string s;
  static int arr[1000];
  cin >> s;
  cin >> k;
  n = s.length();
  if (k > n) {
    printf("0\n");
    return 0;
  }
  for (i = 0; i < n; i++) {
    arr[s[i]]++;
  }
  vector<int> ind;
  vector<int> num;
  int ans;
  temp = k;
  int min;
  for (i = 97; i <= 122; i++) {
    min = 100000;
    for (j = 97; j <= 122; j++) {
      if (arr[j] < min && arr[j] != 0) {
        min = arr[j];
        x = j;
      }
    }
    if (min <= temp) {
      temp = temp - min;
      arr[x] = 0;
    } else
      break;
  }
  int count = 0;
  for (i = 97; i <= 122; i++)
    if (arr[i] != 0) count++;
  printf("%d\n", count);
  for (i = 0; i < n; i++) {
    if (arr[s[i]] != 0) printf("%c", s[i]);
  }
  printf("\n");
  return 0;
}
