#include <bits/stdc++.h>
using namespace std;
inline bool iseq(double x, double y) {
  if (fabs(x - y) < 1e-8) return true;
  return false;
}
template <typename T>
inline T hpt(T x1, T y1, T x2, T y2) {
  return hypot(x1 - x2, y1 - y2);
}
template <typename T>
inline T gcd(T a, T b) {
  if (!b)
    return a;
  else
    return gcd(b, a % b);
}
template <typename T>
inline void extended_euclid(T a, T b, T &x, T &y) {
  if (a % b == 0)
    x = 0, y = 1;
  else {
    extended_euclid(b, a % b, x, y);
    T temp = x;
    x = y;
    y = -y * (a / b) + temp;
  }
}
template <typename T>
inline T bigmod(T b, T p, T m) {
  if (!p)
    return 1;
  else if (!(p % 2)) {
    T x = bigmod(b, p / 2, m);
    return x * x;
  } else
    return ((b % m) * bigmod(b, p - 1, m)) % m;
}
int prime[5 / 32 + 1];
void setbit(int i) {
  int p = i >> 5, q = i & 31;
  prime[p] |= (1 << q);
}
bool checkbit(int i) {
  int p = i >> 5, q = i & 31;
  return prime[p] & (1 << q) ? true : false;
}
void buildprime(int n) {
  int i, j, k = sqrt(double(n));
  prime[0] = 3;
  for (i = 4; i < n; i += 2) setbit(i);
  for (i = 3; i <= k; i += 2) {
    if (!checkbit(i)) {
      int ii = i + i;
      for (j = i * i; j < n; j += ii) setbit(j);
    }
  }
}
int sum, r, n, N, R, C, t, K, txt;
char ch[100005];
struct str {
  char c;
  int f;
};
int F[500];
bool comp(const str &p, const str &q) { return p.f < q.f; }
int main() {
  int i, j, k;
  while (scanf("%s%d", ch, &K) == 2) {
    n = strlen(ch);
    vector<str> V;
    memset(F, 0, sizeof(F));
    for ((i) = (0); (i) < (n); (i)++) {
      F[ch[i]]++;
    }
    for (i = 'a'; i <= 'z'; i++)
      if (F[i]) {
        str tem;
        tem.c = i;
        tem.f = F[i];
        V.push_back(tem);
      }
    sort(V.begin(), V.end(), comp);
    int pos = 0;
    while (K && pos < V.size()) {
      int freq = V[pos].f;
      int lim = min(freq, K);
      int cc = V[pos].c;
      F[cc] -= lim;
      V[pos].f -= lim;
      if (V[pos].f == 0) pos++;
      K -= lim;
    }
    int tot = 0;
    for (i = 'a'; i <= 'z'; i++)
      if (F[i]) tot++;
    cout << tot << endl;
    for ((i) = (0); (i) < (n); (i)++) {
      if (F[ch[i]] > 0) {
        printf("%c", ch[i]);
        F[ch[i]]--;
      }
    }
    printf("\n");
  }
  return 0;
}
