#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,fma")
using namespace std;
template <typename T>
using vc = vector<T>;
template <typename T>
using uset = unordered_set<T>;
template <typename A, typename B>
using umap = unordered_map<A, B>;
template <typename T, typename Comp = less<T>>
using pq = priority_queue<T, vc<T>, Comp>;
template <typename T>
using minpq = pq<T, greater<T>>;
using ld = long double;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using ppi = pair<pii, int>;
using pip = pair<int, pii>;
using vi = vc<int>;
using vii = vc<pii>;
constexpr char el = '\n';
constexpr char sp = ' ';
constexpr int INF = 0x3f3f3f3f;
constexpr ll LLINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int A = 26;
int k;
pii a[A];
string s;
bitset<A> use;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed;
  cin >> s >> k;
  for (int i = 0; i < A; ++i) a[i].second = i;
  for (char c : s) {
    use[c - 'a'] = 1;
    a[c - 'a'].first++;
  }
  sort(a, a + A);
  int ans = 0;
  for (pii p : a) {
    if (p.first + ans > k) break;
    ans += p.first;
    use[p.second] = 0;
  }
  cout << use.count() << el;
  for (char c : s)
    if (use[c - 'a']) cout << c;
}
