#include <bits/stdc++.h>
using namespace std;
int main() {
  string a;
  cin >> a;
  int k, p[256] = {};
  cin >> k;
  for (int i = 0; a[i]; i++) p[a[i]]++;
  while (k) {
    int x = 1e9, y;
    for (int i = 0; i < 256; i++)
      if (p[i] && p[i] < x) x = p[i], y = i;
    if (x == 1e9) break;
    x = min(k, p[y]);
    p[y] -= x, k -= x;
  }
  int ans = 0;
  for (int i = 0; i < 256; i++)
    if (p[i]) ans++;
  cout << ans << endl;
  for (int i = 0; a[i]; i++) {
    if (p[a[i]]) cout << a[i];
  }
}
