#include <bits/stdc++.h>
using namespace std;
int K;
char S[100002];
pair<int, int> A[26];
int C[26];
int main() {
  cin >> S >> K;
  for (int i = 0; i < 26; i++) {
    A[i].first = 0;
    A[i].second = i;
  }
  for (char *c = S; *c; c++) {
    int i = *c - 'a';
    A[i].first++;
  }
  sort(A, A + 26);
  for (int i = 0; i < 26 && K; i++) {
    int mn = min(K, A[i].first);
    A[i].first -= mn;
    K -= mn;
  }
  int ans = 0;
  for (int i = 0; i < 26; i++) {
    int t = C[A[i].second] = A[i].first;
    if (t) ans++;
  }
  cout << ans << endl;
  for (char *c = S; *c; c++) {
    int i = *c - 'a';
    if (C[i] > 0) cout << *c;
    C[i]--;
  }
  cout << endl;
  return 0;
}
