#include <bits/stdc++.h>
using namespace std;
const bool debug = false;
string data;
int k;
pair<int, char> s[26];
int cnt[26];
int main() {
  cin >> data >> k;
  for (int i = 0; i < 26; i++) s[i].second = i + 'a';
  memset(cnt, 0, sizeof(cnt));
  for (size_t i = 0; i < data.length(); i++)
    s[data[i] - 'a'].first++, cnt[data[i] - 'a']++;
  sort(s, s + 26);
  for (int i = 0; i < 26; i++) {
    int x = min(s[i].first, k);
    s[i].first -= x, k -= x;
    cnt[s[i].second - 'a'] -= x;
  }
  if (debug) {
    for (int i = 0; i < 26; i++) cerr << cnt[i] << " ";
    cerr << endl;
  }
  int answer = 0;
  for (int i = 0; i < 26; i++)
    if (cnt[i]) answer++;
  cout << answer << endl;
  for (size_t i = 0; i < data.length(); i++)
    if (cnt[data[i] - 'a']) cout << data[i], cnt[data[i] - 'a']--;
  cout << endl;
  return 0;
}
