#include <bits/stdc++.h>
using namespace std;
long long int N = 1e6;
vector<bool> isprime(N + 1, true);
void seive() {
  isprime[0] = false;
  isprime[1] = false;
  for (int i = 2; i * i <= 1e6; i++) {
    if (isprime[i]) {
      for (int j = i * i; j <= 1e6; j += i) {
        isprime[j] = false;
      }
    }
  }
}
int findfrnd(bitset<32> x, bitset<32> y, int q) {
  int p = 0;
  for (int i = 0; i < 32; i++) {
    if (x[i] != y[i]) {
      p++;
      if (p > q) return 0;
    }
  }
  return 1;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  seive();
  cout << fixed << setprecision(10);
  string s;
  cin >> s;
  int n;
  cin >> n;
  int size = s.length();
  int ch[26] = {0};
  for (int i = 0; i < size; i++) {
    ch[(int)(s[i] - 'a')]++;
  }
  vector<pair<int, int> > v(26);
  for (int i = 0; i < 26; i++) {
    v[i] = {ch[i], i};
  }
  sort(v.begin(), v.end());
  int i = 0;
  while (v[i].first == 0) {
    i++;
  }
  for (; i < 26 && n > 0; i++) {
    if (v[i].first <= n) {
      n -= v[i].first;
      v[i].first = 0;
    } else {
      n = 0;
      break;
    }
  }
  for (int i = 0; i < 26; i++) ch[i] = 0;
  int cnt = 0;
  for (int i = 0; i < 26; i++) {
    if (v[i].first != 0) {
      ch[v[i].second] = 1;
      cnt++;
    }
  }
  string ans = "";
  for (int i = 0; i < size; i++) {
    int ind = (int)(s[i] - 'a');
    if (ch[ind]) {
      ans += s[i];
    }
  }
  if (size <= n)
    cout << 0 << endl;
  else {
    cout << cnt << "\n" << ans << endl;
  }
  return 0;
}
