#include <bits/stdc++.h>
char s[100100];
struct code {
  int n, i;
  bool operator<(const code &rhs) const { return n < rhs.n; }
};
code cnt[50];
bool flag[50];
int main() {
  scanf("%s", s);
  int n = strlen(s);
  memset(cnt, 0, sizeof cnt);
  for (int i = 0; i < n; i++) cnt[s[i] - 'a'].n++;
  for (int i = 0; i < 26; i++) cnt[i].i = i;
  std::sort(cnt, cnt + 26);
  int k;
  scanf("%d", &k);
  for (int i = 0; i < 26; i++) flag[i] = true;
  int now = 0, ans = 0;
  while (k >= cnt[now].n && now < 26)
    k -= cnt[now].n, flag[cnt[now].i] = false, now++;
  for (int i = 0; i < 26; i++)
    if (flag[i]) ans++;
  printf("%d\n", ans);
  for (int i = 0; i < n; i++)
    if (flag[s[i] - 'a']) printf("%c", s[i]);
  return 0;
}
