#include <bits/stdc++.h>
using namespace std;
int n, m;
char s[100005];
int c[26], a[26];
bool cmp(int l, int r) { return c[l] < c[r]; }
int main() {
  scanf("%s", s);
  n = strlen(s);
  scanf("%d", &m);
  for (int i = 0; i < n; ++i) ++c[s[i] - 'a'];
  for (int i = 0; i < 26; ++i) a[i] = i;
  sort(a, a + 26, cmp);
  for (int i = 0; i < 26; ++i) {
    int k = a[i];
    int d = min(m, c[k]);
    c[k] -= d;
    m -= d;
    if (!m) break;
  }
  int ans = 0;
  for (int i = 0; i < 26; ++i)
    if (c[i]) ++ans;
  printf("%d\n", ans);
  if (ans) {
    for (int i = 0; i < n; ++i)
      if (c[s[i] - 'a']) {
        --c[s[i] - 'a'];
        putchar(s[i]);
      }
    puts("");
  }
  return 0;
}
