#include <bits/stdc++.h>
using namespace std;
pair<int, int> cnt[30];
int d[30];
int main() {
  ios_base::sync_with_stdio(false);
  string s;
  int n, k;
  cin >> s >> k;
  n = s.size();
  for (int i = 0; i < 26; ++i) cnt[i] = pair<int, int>(0, 0);
  for (int i = 0; i < n; ++i) cnt[s[i] - 'a'].first++;
  for (int i = 0; i < 26; ++i) cnt[i].second = i;
  sort(cnt, cnt + 26);
  for (int i = 0; i < 26; ++i) {
    int cur = min(k, cnt[i].first);
    k -= cur;
    cnt[i].first -= cur;
  }
  for (int i = 0; i < 26; ++i) d[cnt[i].second] = cnt[i].first;
  int res = 0;
  for (int i = 0; i < 26; ++i) res += (d[i] > 0);
  cout << res << '\n';
  for (int i = 0; i < n; ++i)
    if (d[s[i] - 'a']) {
      cout << s[i];
      d[s[i] - 'a']--;
    }
  cout << '\n';
  return 0;
}
