#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:100000000")
using namespace std;
const bool db = false;
long long st[26], dop[26];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  string s;
  cin >> s;
  long long k;
  cin >> k;
  for (long long i = 0; i < s.length(); i++) st[s[i] - 'a']++;
  for (long long i = 0; i < 26; i++) {
    long long min_ = 1000000007, pos = 0;
    for (long long j = 0; j < 26; j++)
      if (st[j] && st[j] < min_) min_ = min(min_, st[j]), pos = j;
    if (min_ == 1000000007) {
      cout << "0\n";
      return 0;
    } else if (k >= min_) {
      k -= st[pos];
      st[pos] = 0;
    } else {
      st[pos] -= k;
      break;
    }
  }
  long long count = 0;
  for (long long i = 0; i < 26; i++)
    if (st[i]) count++;
  cout << count << "\n";
  for (long long i = 0; i < s.size(); i++)
    if (dop[s[i] - 'a'] < st[s[i] - 'a']) {
      cout << s[i];
      dop[s[i] - 'a']++;
    }
  cout << "\n";
  return 0;
}
