#include <bits/stdc++.h>
using namespace std;
int main() {
  string h;
  cin >> h;
  int y, counter = 0;
  cin >> y;
  int arr[26];
  for (int i = 0; i < 26; i++) arr[i] = 0;
  for (int i = 0; i < h.size(); i++) {
    arr[(int)(h[i] - 97)] += 1;
  }
  int min = 100000000;
  for (int i = 0; i < 26; i++) {
    bool flag = true;
    min = 10000000;
    int s = 0;
    for (int j = 0; j < 26; j++) {
      if (min > arr[j] && arr[j] != 0) {
        min = arr[j];
        flag = false;
        s = j;
      }
    }
    if (y >= min) {
      y -= min;
      arr[s] = 0;
    }
    if (flag) min = 0;
  }
  for (int i = 0; i < 26; i++)
    if (arr[i] != 0) counter++;
  cout << counter << endl;
  for (int i = 0; i < h.size(); i++) {
    if (arr[(int)(h[i] - 97)] != 0) cout << h[i];
  }
  cout << endl;
  return 0;
}
