#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  long long k;
  int size = 0;
  cin >> s >> k;
  if (k > s.length()) {
    cout << "0\n\n";
    return 0;
  }
  vector<pair<int, string> > all;
  string stat = "";
  for (int i = 0; i < s.length(); i++) stat += '0';
  for (int i = 0; i < s.length(); i++) {
    string temp = "";
    if (stat[i] != '0') continue;
    for (int j = 0; j < s.length(); j++)
      if (s[j] == s[i] && stat[j] == '0') {
        temp += s[j];
        stat[j] = '1';
      }
    all.push_back(make_pair(temp.length(), temp));
    size++;
  }
  sort(all.begin(), all.end());
  int sum = 0;
  string del = "";
  for (int f = 0; f < all.size(); f++) {
    if (sum + all[f].first <= k) {
      sum += all[f].first;
      string temp;
      temp = all[f].second;
      del += temp[0];
    } else
      break;
  }
  string fin = "";
  for (int i = 0; i < s.length(); i++)
    if (!(del.find(s[i]) >= 0 && del.find(s[i]) < del.length())) fin += s[i];
  cout << size - del.size() << endl;
  cout << fin << endl;
  return 0;
}
