#include <bits/stdc++.h>
using namespace std;
const int oo = (int)1e9;
const double PI = 2 * acos(0.0);
const double eps = 1e-9;
pair<int, int> arr[26];
int main() {
  ios_base::sync_with_stdio(false);
  string s;
  int n;
  cin >> s;
  cin >> n;
  for (int i = 0; i < (int)(((long long)s.size())); ++i) {
    arr[s[i] - 'a'].first++;
    arr[s[i] - 'a'].second = s[i] - 'a';
  }
  sort(arr, arr + 26);
  for (int i = 0; i < (int)(26); ++i) {
    if (arr[i].first <= n) n -= arr[i].first, arr[i].first = 0;
  }
  int cnt[26] = {0}, ans = 0;
  for (int i = 0; i < (int)(26); ++i) {
    cnt[arr[i].second] = arr[i].first;
  }
  for (int i = 0; i < (int)(26); ++i)
    if (cnt[i]) ++ans;
  cout << ans << endl;
  for (int i = 0; i < (int)(((long long)s.size())); ++i)
    if (cnt[s[i] - 'a']) cout << s[i];
  return 0;
}
