#include <bits/stdc++.h>
using namespace std;
static const double EPS = 1e-10;
template <typename T, typename S>
vector<T>& operator<<(vector<T>& a, S b) {
  a.push_back(b);
  return a;
}
template <typename T>
void operator>>(vector<T>& a, int b) {
  while (b--)
    if (!a.empty()) a.pop_back();
}
bool isprime(int n) {
  if (n < 2) return false;
  for (int i = 2; i * i <= n; i++)
    if (n % i == 0) return false;
  return true;
}
long long b_pow(long long x, long long n) {
  return n ? n == 1 ? x : b_pow(x, n >> 1) * b_pow(x, (n >> 1) + (n & 1)) : 1;
}
string itos(int n) {
  stringstream ss;
  ss << n;
  return ss.str();
}
int main() {
  ios_base::sync_with_stdio(true);
  string s;
  cin >> s;
  int m;
  cin >> m;
  vector<pair<int, int> > v;
  for (int i = 0; i < 26; i++)
    v.push_back(make_pair(count(s.begin(), s.end(), 'a' + i), i));
  sort(v.begin(), v.end());
  for (int i = 0; i < 26; i++)
    while (v[i].first && m) v[i].first--, m--;
  int d[26] = {0};
  for (int i = 0; i < 26; i++) d[v[i].second] = v[i].first;
  string ans;
  cout << 26 - count(d, d + 26, 0) << endl;
  for (int i = 0; i < s.size(); i++)
    if (d[s[i] - 'a']) ans += s[i], d[s[i] - 'a']--;
  cout << ans << endl;
}
