#include <bits/stdc++.h>
using namespace std;
long long a[1000010], b[1000], d[100010][26], p[10010];
long long mn = 1e18, mx = -1e18, ans, cnt, sm = 1, n, m;
bool ok, okk, u[1000010], uu[310][310], uk[1000010];
char ck[510][510], ch[100010];
int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
vector<int> g[900010];
int main() {
  vector<pair<int, char> > v;
  string s;
  cin >> s;
  long long k;
  cin >> k;
  if (k >= s.size()) {
    cout << 0;
    return 0;
  }
  for (int i = 0; i < s.size(); i++) {
    a[s[i] - 'a']++;
  }
  for (int i = 0; i < 26; i++) {
    if (a[i]) {
      ans++;
    }
    v.push_back(make_pair(a[i], char(i + 'a')));
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < v.size(); i++) {
  }
  for (int i = 0; i < 26; i++) {
    if (k == 0) {
      break;
    } else {
      if (v[i].first < k && v[i].first != 0) {
        k -= v[i].first;
        v[i].first = 0;
        ans--;
      } else if (v[i].first == k && v[i].first != 0) {
        v[i].first = 0;
        k = 0;
        ans--;
        break;
      }
    }
  }
  cout << ans << endl;
  for (int i = 0; i < s.size(); i++) {
    for (int j = 0; j < 26; j++) {
      if (v[j].second == s[i]) {
        if (v[j].first > 0) {
          cout << s[i];
          v[j].first--;
          break;
        }
      }
    }
  }
  return 0;
}
