#include <bits/stdc++.h>
using namespace std;
string s;
int k;
pair<int, int> cnt[26];
bool deleted[26];
int main() {
  cin.sync_with_stdio(0);
  cin >> s;
  cin >> k;
  for (int i = 0; i < s.size(); 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++)
    if (cnt[i].first <= k) {
      deleted[cnt[i].second] = true;
      k -= cnt[i].first;
    }
  int ans = 0;
  for (int i = 0; i < 26; i++)
    if (!deleted[i]) ans++;
  printf("%d\n", ans);
  for (int i = 0; i < s.size(); i++)
    if (!deleted[s[i] - 'a']) printf("%c", s[i]);
  printf("\n");
  return 0;
}
