#include <bits/stdc++.h>
using namespace std;
struct Ch {
  char ch;
  int n;
};
Ch a[100];
int mark[1000];
inline bool operator<(const Ch &a, const Ch &b) { return a.n < b.n; }
int k;
int main() {
  string s;
  cin >> s >> k;
  for (char i = 'a'; i <= 'z'; i++) {
    a[i - 'a'].ch = (char)(i);
    a[i - 'a'].n = 0;
  }
  for (int i = 0; i < s.length(); i++) {
    a[(s[i]) - 'a'].n++;
  }
  sort(a, a + 'z' - 'a' + 1);
  int ans = 'z' - 'a' + 1;
  for (int i = 0; i < 'z' - 'a' + 1; i++) {
    if (a[i].n == 0) {
      ans--;
      continue;
    }
    if (a[i].n <= k) {
      ans--;
      k -= a[i].n;
      mark[a[i].ch] = 1;
    }
    if (a[i].n > k) break;
  }
  cout << ans << endl;
  for (int i = 0; i < s.length(); i++) {
    if (!mark[s[i]]) cout << s[i];
  }
  if (ans != 0) cout << endl;
}
