#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > v;
bool del[26];
int main() {
  string s;
  int m = 0, k, d = 0, num = 0;
  cin >> s >> k;
  for (int i = 0; i < 26; ++i) v.push_back(pair<int, int>(0, i));
  for (int i = 0; i < s.length(); ++i) v[s[i] - 'a'].first++;
  sort(v.begin(), v.end());
  for (int i = 0; i < 26; ++i) {
    if (d >= k) break;
    if (v[i].first == 0) continue;
    d += v[i].first;
    if (d > k) break;
    if (!del[v[i].second]) m++;
    del[v[i].second] = true;
  }
  for (int i = 0; i < 26; ++i)
    if (v[i].first != 0) num++;
  cout << num - m << endl;
  for (int i = 0; i < s.length(); ++i)
    if (!del[s[i] - 'a']) cout << s[i];
  cout << endl;
  cin >> s;
  return 0;
}
