#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
const int maxn = 1e5 + 9;
int num[30];
struct A {
  int id;
  int v;
} a[30];
bool cmp(A a, A b) { return a.v < b.v; }
int main() {
  ios::sync_with_stdio(false);
  string s;
  int k;
  while (cin >> s >> k) {
    memset(num, 0, sizeof(num));
    int n = s.length();
    for (int i = 0; i < n; i++) {
      num[s[i] - 'a']++;
    }
    int cnt = 0;
    for (int i = 0; i < 26; i++) {
      if (num[i]) {
        a[cnt].id = i;
        a[cnt].v = num[i];
        cnt++;
      }
    }
    int kk = 0;
    sort(a, a + cnt, cmp);
    for (int i = 0; i < cnt; i++) {
      if (k >= a[i].v) {
        kk++;
        for (int j = 0; j < n; j++) {
          if (s[j] - 'a' == a[i].id) {
            s[j] = '#';
          }
        }
        k -= a[i].v;
      } else
        break;
    }
    cout << cnt - kk << endl;
    for (int i = 0; i < n; i++) {
      if (s[i] != '#') cout << s[i];
    }
    if (cnt - kk != 0) cout << endl;
  }
  return 0;
}
