#include <bits/stdc++.h>
using namespace std;
string s;
int n, ans = 0;
vector<pair<int, int>> b;
vector<int> a(26);
int main() {
  cin >> s >> n;
  for (int i = 0; i < s.length(); ++i) {
    a[s[i] - 'a']++;
  }
  for (int i = 0; i < 26; ++i) {
    b.push_back(make_pair(a[i], i));
  }
  sort(b.begin(), b.end());
  for (int i = 0; i < 26; ++i) {
    if (n >= b[i].first) {
      n -= b[i].first;
      b[i].first = 0;
    }
  }
  for (int i = 0; i < 26; ++i) {
    if (b[i].first != 0) ans++;
  }
  cout << ans << endl;
  for (int i = 0; i < s.length(); ++i) {
    for (int j = 0; j < 26; ++j) {
      if (s[i] - 'a' == b[j].second && b[j].first > 0) {
        cout << s[i];
      }
    }
  }
  return 0;
}
