#include <bits/stdc++.h>
using namespace std;
struct st {
  char a;
  long long countt;
};
st ar[27];
bool cmp(const st &a, const st &b) {
  if (a.countt == b.countt) {
    return a.a < b.a;
  }
  return a.countt < b.countt;
}
string removee(char c, string s) {
  string ans = "";
  for (long long i = 0; i < s.size(); i++) {
    if (s[i] != c) {
      ans += s[i];
    }
  }
  return ans;
}
int main() {
  string s;
  long long k;
  for (long long i = 0; i < 27; i++) {
    ar[i].a = i + 'a';
    ar[i].countt = 0;
  }
  cin >> s >> k;
  if (s.size() < k) {
    cout << 0;
    return 0;
  }
  for (long long i = 0; i < s.size(); i++) {
    ar[s[i] - 'a'].countt++;
  }
  sort(ar, ar + 27, cmp);
  long long start = 0;
  while (ar[start].countt != 0) {
    start++;
  }
  long long endd;
  for (long long i = start; i < 27; i++) {
    k -= ar[i].countt;
    if (k < 0) {
      endd = i;
      break;
    }
  }
  for (long long i = start; i < endd; i++) {
    s = removee(ar[i].a, s);
  }
  cout << 27 - endd << endl << s;
  return 0;
}
