#include <bits/stdc++.h>
using namespace std;
struct comp {
  bool operator()(const pair<int, int> &a, const pair<int, int> &b) {
    return a.second < b.second;
  }
};
int main() {
  int k, m, l, ans = 0;
  string s;
  cin >> s >> k;
  l = s.length();
  int a[26] = {0};
  vector<pair<int, int> > v;
  for (int i = 0; i < l; ++i) a[s[i] - 'a']++;
  for (int i = 0; i < 26; ++i)
    if (a[i]) v.push_back(make_pair(i, a[i]));
  sort(v.begin(), v.end(), comp());
  ans = v.size();
  bool del[26] = {0};
  for (int i = 0; i < v.size(); ++i) {
    if (v[i].second <= k) {
      k -= v[i].second;
      ans--;
      del[v[i].first] = 1;
    } else
      break;
  }
  cout << ans << endl;
  for (int i = 0; i < l; ++i) {
    if (!del[s[i] - 'a']) cout << s[i];
  }
  cout << endl;
  return 0;
}
