#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
int n, k;
char s[100001];
int cnt[26];
int rem[26];
void solution() {
  gets(s);
  n = strlen(s);
  scanf("%d", &k);
  for (int i = 0, _n = (n); i < _n; ++i) cnt[s[i] - 'a']++;
  vector<pair<int, int> > v;
  for (int i = 0, _n = (26); i < _n; ++i)
    v.push_back(pair<int, int>(cnt[i], i));
  sort((v).begin(), (v).end());
  int ret = 26;
  for (int i = 0, _n = (26); i < _n; ++i) {
    if (k < v[i].first) {
      v[i].first -= k;
      cnt[v[i].second] -= k;
      k = 0;
    } else {
      k -= v[i].first;
      v[i].first = 0;
      cnt[v[i].second] = 0;
      ret--;
    }
  }
  cout << ret << endl;
  for (int i = 0, _n = (n); i < _n; ++i)
    if (cnt[s[i] - 'a']) {
      putchar(s[i]);
      cnt[s[i] - 'a']--;
    }
  cout << endl;
}
int main() {
  solution();
  return 0;
}
