#include <bits/stdc++.h>
using namespace std;
string s;
int n;
int a[26];
int b[26];
bool flag[26];
bool cmp(int x, int y) { return a[x] < a[y]; }
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> s >> n;
  memset(a, 0, sizeof(a));
  memset(flag, 1, sizeof(flag));
  for (int i = 0; i < s.size(); ++i) {
    a[s[i] - 'a']++;
  }
  for (int i = 0; i < 26; ++i) {
    b[i] = i;
  }
  int ans = 26;
  sort(b, b + 26, cmp);
  for (int i = 0; i < 26; ++i) {
    if (a[b[i]] <= n) {
      flag[b[i]] = 0;
      n -= a[b[i]];
      ans--;
    }
  }
  cout << ans << "\n";
  for (int i = 0; i < s.size(); ++i) {
    if (flag[s[i] - 'a']) cout << s[i];
  }
  return 0;
}
