#include <bits/stdc++.h>
using namespace std;
int n, k, ans = 0;
string s;
vector<int> cnt(26, 0);
vector<pair<char, int> > arr(1e5 + 5);
bool comp1(pair<char, int>& a, pair<char, int>& b) {
  if (cnt[a.first - 97] < cnt[b.first - 97]) {
    return true;
  } else if (cnt[a.first - 97] == cnt[b.first - 97]) {
    return a.first < b.first;
  }
  return false;
}
bool comp2(pair<char, int>& a, pair<char, int>& b) {
  return a.second < b.second;
}
int main(void) {
  ios ::sync_with_stdio(0);
  cin.tie(0);
  cin >> s >> k;
  n = s.length();
  k = min(n, k);
  for (int i = 0; i <= n - 1; ++i) {
    arr[i + 1] = {s[i], i + 1};
    ++cnt[s[i] - 97];
  }
  sort(arr.begin() + 1, arr.begin() + n + 1, comp1);
  sort(arr.begin() + k + 1, arr.begin() + n + 1, comp2);
  s = "";
  fill(cnt.begin(), cnt.end(), 0);
  for (int i = k + 1; i <= n; ++i) {
    s += arr[i].first;
    if (cnt[arr[i].first - 97] == 0) {
      ++ans;
      cnt[arr[i].first - 97] = 1;
    }
  }
  cout << ans << "\n" << s << "\n";
  return 0;
}
