#include <bits/stdc++.h>
using namespace std;
const long double eps = 1e-9;
const int inf = (int)1e9;
const long long linf = (long long)1e18;
const long double pi = acos(-1.0);
const int prime = 748297;
inline void finclude() { srand(time(NULL)); }
struct cmp {
  bool operator()(const pair<int, char>& a, pair<int, char>& b) {
    return (a.first < b.first);
  }
};
int main() {
  string s;
  long long k;
  cin >> s >> k;
  int n = s.length();
  vector<pair<int, char> > a('z' - 'a' + 1);
  for (int i = 0; i < 'z' - 'a' + 1; ++i) {
    a[i].second = i + 'a';
    a[i].first = 0;
  }
  for (int i = 0; i < n; ++i) ++a[s[i] - 'a'].first;
  sort(a.begin(), a.end());
  vector<bool> t('z' - 'a' + 1, true);
  for (int i = 0; i < 'z' - 'a' + 1; ++i) {
    if (a[i].first <= k) {
      k -= a[i].first;
      t[a[i].second - 'a'] = false;
      a[i].first = 0;
    }
  }
  int count = 0;
  for (int i = 0; i < 'z' - 'a' + 1; ++i)
    if (a[i].first > 0) ++count;
  cout << count << '\n';
  for (int i = 0; i < n; ++i)
    if (t[s[i] - 'a']) cout << s[i];
  cout << '\n';
}
