#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, a[26], p = 0, t = 0, k;
  for (i = 0; i < 26; i++) a[i] = 0;
  string s;
  cin >> s >> k;
  n = s.length();
  if (k > n) {
    cout << "impossible";
    return 0;
  }
  for (i = 0; i < n; i++) a[int(s[i]) - int('a')]++;
  for (i = 0; i < 26; i++) {
    if (a[i] > 0) t++;
    if (a[i] > 1) p = p + a[i] - 1;
  }
  if (k - t >= 0) {
    if (t + p >= k)
      cout << k - t;
    else
      cout << "impossible";
  } else
    cout << 0;
  return 0;
}
