#include <bits/stdc++.h>
using namespace std;
const int MOD = 998244353;
int N = 1e5 + 7;
void swap(char *p, char *q) {
  char temp = *p;
  *p = *q;
  *q = temp;
  return;
}
long long int powxy(long long int x, long long int y) {
  if (y == 0) return 1;
  if (y % 2 == 1) return (x * powxy(x, y - 1)) % N;
  long long int t = powxy(x, y / 2);
  return (t * t) % N;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  string s;
  cin >> s;
  int k;
  cin >> k;
  vector<pair<int, char> > v(26);
  for (int i = 0; i < 26; i++) {
    v[i].first = 0;
    v[i].second = 'a' + i;
  }
  for (int i = 0; i < s.length(); i++) {
    v[s[i] - 'a'].first++;
  }
  sort(v.begin(), v.end());
  int cnt = 0;
  for (int i = 0; i < 26; i++) {
    if (v[i].first != 0 && k > 0) {
      if (v[i].first <= k) {
        k -= v[i].first;
        v[i].first = 0;
      } else {
        v[i].first -= k;
        k = 0;
      }
    }
  }
  int sum = 0;
  for (int i = 0; i < 26; i++)
    if (v[i].first != 0) {
      sum++;
    }
  cout << sum << "\n";
  int h[26] = {};
  for (int i = 0; i < 26; i++) {
    h[v[i].second - 'a'] = v[i].first;
  }
  for (int j = 0; j < s.length(); j++) {
    if (h[s[j] - 'a'] > 0) {
      cout << s[j];
      h[s[j] - 'a']--;
    }
  }
}
