#include <bits/stdc++.h>
using namespace std;
using LL = long long;
string s;
int k;
int c[26];
bool st[26];
int main() {
  cin >> s >> k;
  memset(c, 0, sizeof(c));
  for (auto &i : s) c[i - 'a']++;
  memset(st, 1, sizeof(st));
  while (k >= 0) {
    int idx;
    int minx = 1e5 + 5;
    for (decay<decltype(25)>::type i = (0), _i = (25); i <= _i; ++i) {
      if (st[i] && c[i] < minx) {
        minx = c[i];
        idx = i;
      }
    }
    if (k < minx) break;
    st[idx] = 0;
    k -= minx;
  }
  int ans = 0;
  for (decay<decltype(25)>::type i = (0), _i = (25); i <= _i; ++i) {
    if (st[i]) ans++;
  }
  cout << ans << endl;
  for (auto &i : s) {
    if (st[i - 'a']) printf("%c", i);
  }
  printf("\n");
  return 0;
}
