#include <bits/stdc++.h>
using namespace std;
const int M = 998244353;
long long mod(long long x) { return ((x % M + M) % M); }
long long add(long long a, long long b) { return mod(mod(a) + mod(b)); }
long long mul(long long a, long long b) { return mod(mod(a) * mod(b)); }
long long modPow(long long a, long long b) {
  if (b == 0) return 1LL;
  if (b == 1) return a % M;
  long long res = 1;
  while (b) {
    if (b % 2 == 1) res = mul(res, a);
    a = mul(a, a);
    b = b / 2;
  }
  return res;
}
int main() {
  string s;
  long long k;
  cin >> s;
  cin >> k;
  priority_queue<pair<long long, long long>> pq;
  vector<int> cnt(26, 0);
  long long n = s.length();
  for (int i = 0; i < n; i++) cnt[s[i] - 'a']++;
  for (int i = 0; i < 26; i++) pq.push({-cnt[i], i});
  vector<bool> remo(26, 0);
  while (!pq.empty() && k > 0) {
    pair<int, int> a = pq.top();
    pq.pop();
    a.first = a.first * -1;
    if (a.first > k) break;
    k -= a.first;
    remo[a.second] = 1;
  }
  set<long long> si;
  for (auto i : s)
    if (!remo[i - 'a']) si.insert(i - 'a');
  cout << si.size() << endl;
  for (auto i : s)
    if (!remo[i - 'a']) cout << i;
  return 0;
}
