#include <bits/stdc++.h>
using namespace std;
int num[500];
int main() {
  string s;
  cin >> s;
  for (int i = 0; i < s.length(); i++) num[s[i]]++;
  int k;
  cin >> k;
  while (true) {
    int min = 1000000;
    int ind = -1;
    for (int i = 'a'; i <= 'z'; i++)
      if (num[i] > 0 && num[i] < min) {
        min = num[i];
        ind = i;
      }
    if (ind == -1) break;
    if (k < min)
      break;
    else {
      k -= min;
      num[ind] = 0;
    }
  }
  int ans = 0;
  for (int i = 'a'; i <= 'z'; i++)
    if (num[i] > 0) ans++;
  cout << ans << endl;
  for (int i = 0; i < s.length(); i++)
    if (num[s[i]] > 0) cout << s[i];
  cout << endl;
  return 0;
}
