#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int k;
  cin >> k;
  map<char, int> dict;
  for (int i = 0; i < 27; i++) dict[i + 'a'] = 0;
  for (int i = 0; i < s.length(); i++) dict[s[i]]++;
  map<char, int>::iterator it;
  vector<pair<int, char> > letras;
  pair<int, char> aux;
  int distinto;
  for (it = dict.begin(); it != dict.end(); ++it) {
    aux = make_pair((*it).second, (*it).first);
    if (aux.first != 0) letras.push_back(aux);
  }
  sort((letras).begin(), (letras).end());
  distinto = letras.size();
  int l = 0;
  int j = 0;
  while (true) {
    j += letras[l].first;
    if (j > k) break;
    l++;
    if (j == k) break;
    if (l == distinto) break;
  }
  if (l == distinto) {
    cout << 0 << endl;
    cout << endl;
    return 0;
  }
  bool ltras[28];
  memset(ltras, 0, sizeof(ltras));
  for (int i = l; i < letras.size(); i++) {
    ltras[letras[i].second - 'a'] = 1;
  }
  string res = "";
  for (int i = 0; i < s.length(); i++)
    if (ltras[s[i] - 'a']) res += s[i];
  cout << distinto - l << endl;
  cout << res << endl;
  return 0;
}
