#include <bits/stdc++.h>
using namespace std;
const int INF = (1LL << 31) - 1;
struct node {
  int x, y;
};
bool cmp(node x, node y) { return x.y < y.y; }
node p[26];
bool b[26];
string s;
int k, ans = 26;
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> s >> k;
  for (int i = 0; i < 26; i++) p[i].x = i;
  for (char c : s) p[c - 'a'].y++;
  sort(p, p + 26, cmp);
  for (int i = 0; i < 26; i++) {
    if (k < p[i].y) break;
    b[p[i].x] = 1;
    k -= p[i].y;
    ans--;
  }
  cout << ans << endl;
  for (char c : s)
    if (!b[c - 'a']) cout << c;
  cout << endl;
}
