#include <bits/stdc++.h>
using namespace std;
int fx[] = {1, -1, 0, 0};
int fy[] = {0, 0, 1, -1};
class data {
 public:
  int cc;
  int freq;
  data() {}
  data(int a, int b) {
    cc = a;
    freq = b;
  }
  bool operator<(const data& b) const { return freq < b.freq; }
};
vector<data> vv;
string ss;
int k;
int yo[250];
int main() {
  std::ios_base::sync_with_stdio(false);
  cin >> ss;
  cin >> k;
  for (int i = 0; i <= (int)ss.size() - 1; i++) {
    yo[ss[i]]++;
  }
  for (int i = 'a'; i <= 'z'; i++) {
    vv.push_back(data(i, yo[i]));
  }
  sort(vv.begin(), vv.end());
  for (int i = 0; i <= vv.size() - 1; i++) {
    yo[vv[i].cc] -= min(vv[i].freq, k);
    k -= min(vv[i].freq, k);
  }
  int ans = 0;
  for (int i = 'a'; i <= 'z'; i++) {
    if (yo[i]) {
      ans++;
    }
  }
  cout << ans << "\n";
  for (int i = 0; i <= (int)ss.size() - 1; i++) {
    if (yo[ss[i]]) {
      cout << ss[i];
      yo[ss[i]]--;
    }
  }
  return 0;
}
