#include <bits/stdc++.h>
using namespace std;
const int oo = (int)1e9 + 7;
const int N = 300;
vector<int> adj[N];
bool comp(const pair<char, int>& a, const pair<char, int>& b) {
  return a.second < b.second;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie();
  cout.tie();
  int k;
  string s;
  cin >> s >> k;
  map<char, int> cnt;
  for (int i = 0; i < (int)((s).size()); ++i) {
    adj[s[i]].push_back(i);
    cnt[s[i]]++;
  }
  int m = (int)((cnt).size());
  vector<pair<char, int> > v(((cnt).begin()), ((cnt).end()));
  sort(((v).begin()), ((v).end()), comp);
  for (int i = 0; i < (int)((v).size()) && k > 0; ++i) {
    const char& ch = v[i].first;
    int& x = v[i].second;
    int kk = min(k, x);
    for (int j = 0; j < (int)((adj[ch]).size()) && j < kk; ++j) {
      int pos = adj[ch][j];
      s[pos] = '#';
    }
    k -= kk;
    x -= kk;
    if (!x) --m;
  }
  cout << m << endl;
  for (int i = 0; i < (int)((s).size()); ++i)
    if (s[i] != '#') cout << s[i];
  cin.ignore();
  cin.get();
}
