#include <bits/stdc++.h>
using namespace std;
int MOD = 1e9 + 7;
const long double E = 1e-8;
unsigned char ccc;
bool _minus = false;
inline void read(int &n) {
  n = 0;
  _minus = false;
  while (true) {
    ccc = getchar();
    if (ccc == ' ' || ccc == '\n') break;
    if (ccc == '-') {
      _minus = true;
      continue;
    }
    n = n * 10 + ccc - '0';
  }
  if (_minus) n *= -1;
}
char wwww[12];
int kkkk;
inline void write(int x) {
  kkkk = 0;
  if (!x)
    ++kkkk, wwww[kkkk] = '0';
  else
    while (x) {
      ++kkkk;
      wwww[kkkk] = char(x % 10 + '0');
      x /= 10;
    }
  for (int i = kkkk; i >= 1; --i) putchar(wwww[i]);
  putchar('\n');
}
template <typename T>
inline T sqr(T t) {
  return t * t;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  srand(time(NULL));
  cout.precision(10);
  cout << fixed;
  string s;
  cin >> s;
  int n = (int)s.size();
  int k;
  cin >> k;
  k = min(k, n);
  vector<pair<int, vector<int> > > v(26);
  for (int i = 0; i < n; i++) {
    int t = s[i] - 'a';
    v[t].first++;
    v[t].second.push_back(i);
  }
  sort(v.begin(), v.end());
  bool used[n];
  memset(used, 0, sizeof(used));
  for (int i = 0; i < 26; i++) {
    for (int j = 0; j < (int)v[i].second.size(); j++) {
      if (k) {
        used[v[i].second[j]] = true;
        k--;
      }
    }
  }
  set<char> st;
  for (int i = 0; i < n; i++) {
    if (!used[i]) {
      st.insert(s[i]);
    }
  }
  cout << st.size() << "\n";
  for (int i = 0; i < n; i++)
    if (!used[i]) cout << s[i];
  cout << "\n";
}
