#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > dp;
int main() {
  string s;
  cin >> s;
  int k;
  cin >> k;
  int i;
  int n = s.length();
  for (i = 0; i < 26; i++) {
    pair<int, int> p;
    p.first = 0;
    p.second = i;
    dp.push_back(p);
  }
  for (i = 0; i < n; i++) {
    dp[s[i] - 'a'].first++;
  }
  sort(dp.begin(), dp.end());
  vector<int> remove(26);
  int count = 0;
  for (i = 0; i < 26; i++) {
    while (k > 0 && dp[i].first > 0) {
      remove[dp[i].second]++;
      dp[i].first--;
      k--;
    }
    if (dp[i].first > 0) count++;
  }
  string ans = "";
  for (i = 0; i < n; i++) {
    if (remove[s[i] - 'a'] > 0)
      remove[s[i] - 'a']--;
    else
      ans += s[i];
  }
  cout << count << "\n";
  cout << ans << "\n";
  return 0;
}
