#include <bits/stdc++.h>
using namespace std;
void file() {}
void fast() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
}
long long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; }
int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
int main() {
  file();
  fast();
  string s;
  cin >> s;
  int k;
  cin >> k;
  vector<vector<int>> f(26, vector<int>(2));
  for (int i = 0; i < 26; i++) f[i][0] = 0, f[i][1] = i;
  for (char i : s) f[i - 'a'][0]++;
  vector<int> a(26, 1);
  sort(f.begin(), f.end());
  int sum = 26;
  for (int i = 0; i < 26; i++)
    if (f[i][0] <= k) {
      k -= f[i][0];
      a[f[i][1]] = 0;
      sum--;
    }
  cout << sum << endl;
  for (char i : s)
    if (a[i - 'a']) cout << i;
}
