#include <bits/stdc++.h>
using namespace std;
int pin[30];
int check[30];
int main() {
  string s;
  cin >> s;
  int k;
  cin >> k;
  int x = s.size();
  for (int i = 0; i < x; i++) {
    pin[s[i] - 'a']++;
  }
  int counter = 0;
  for (int i = 0; i < 28; i++) {
    if (pin[i] == 0) {
      pin[i] = 1000000;
    } else
      counter++;
  }
  while (1) {
    int minn = *min_element(pin, pin + 26);
    if (k < minn) {
      break;
    }
    for (int i = 0; i < 26; i++) {
      if (k >= minn) {
        if (pin[i] == minn) {
          check[i] = 1;
          k -= minn;
          pin[i] = 1000000;
          counter--;
        }
      }
    }
  }
  cout << counter << endl;
  for (int i = 0; i < x; i++) {
    if (check[s[i] - 'a'] == 0) {
      cout << s[i];
    }
  }
  return 0;
}
