#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr);
  string strng;
  cin >> strng;
  int k;
  cin >> k;
  int a[26] = {0};
  for (int i = 0; i < strng.size(); i++) a[strng[i] - 'a']++;
  if (k == 0) {
    string b;
    for (int i = 0; i < strng.size(); i++) {
      if (a[strng[i] - 'a']) b += strng[i], a[strng[i] - 'a'] = 0;
    }
    cout << b.size() << "\n" << strng << "\n";
    return 0;
  }
  vector<pair<int, char>> v;
  for (int i = 0; i < 26; i++) v.push_back({a[i], (char)(i + 'a')});
  sort(v.begin(), v.end());
  ;
  int i;
  for (i = 0; i < 26; i++) {
    k -= v[i].first;
    if (k == 0) {
      v[i].first = 0;
      break;
    } else if (k < 0) {
      v[i].first = -1 * k;
      break;
    } else
      v[i].first = 0;
  }
  int ans = 0;
  for (int j = i; j < 26; j++) {
    if (v[j].first > 0) ans++;
  }
  cout << ans << "\n";
  map<char, int> mp;
  for (int i = 0; i < 26; i++) {
    mp[v[i].second] = v[i].first;
  }
  string out = "";
  for (int i = 0; i < strng.size(); i++) {
    if (mp[strng[i]]) {
      mp[strng[i]]--;
      out += strng[i];
    }
  }
  cout << out << "\n";
}
