#include <bits/stdc++.h>
using namespace std;
int s[30];
char c[100010];
int n, k;
struct node {
  int id, v;
};
node nn[30];
bool cmp(node a, node b) { return a.v < b.v; }
int main() {
  while (cin >> c >> k) {
    n = strlen(c);
    for (int i = 0; i < 30; i++) s[i] = 0;
    for (int i = 0; i < n; i++) s[(c[i] - 'a')]++;
    for (int i = 0; i < 30; i++) nn[i].id = i, nn[i].v = s[i];
    sort(nn, nn + 30, cmp);
    int p = 0, sum = 0;
    while (nn[p].v <= k && p < 30) {
      k -= nn[p].v;
      s[nn[p].id] = 0;
      p++;
    }
    for (int i = 0; i < 26; i++)
      if (s[i] > 0) sum++;
    cout << sum << endl;
    for (int i = 0; i < n; i++)
      if (s[(c[i] - 'a')] != 0) printf("%c", c[i]);
    printf("\n");
  }
}
