#include <bits/stdc++.h>
using namespace std;
int main() {
  int count[27];
  memset(count, 0, sizeof(count));
  string word;
  cin >> word;
  for (int i = 0; i < word.length(); ++i) {
    count[word[i] - 'a']++;
  }
  int k;
  cin >> k;
  int nro = 0;
  vector<pair<int, int> > v;
  for (int i = 0; i < 26; ++i) {
    if (count[i] != 0) {
      v.push_back(make_pair(count[i], i));
      nro++;
    }
  }
  sort((v).begin(), (v).end());
  int n = v.size();
  int p = -1;
  for (int i = 0; i < n; ++i) {
    if (v[i].first > k) {
      p = i;
      break;
    }
    k -= v[i].first;
    count[v[i].second] = 0;
    nro--;
  }
  if (p == -1)
    cout << 0 << endl;
  else {
    cout << nro << endl;
    for (int i = 0; i < word.length(); ++i) {
      if (count[word[i] - 'a'] != 0) cout << word[i];
    }
    cout << endl;
  }
  return 0;
}
