#include <bits/stdc++.h>
using namespace std;
void scan(int &x) {
  bool neg = false;
  register int c;
  x = 0;
  c = getchar();
  if (c == '-') {
    neg = true;
    c = getchar();
  }
  for (; (c > 47 && c < 58); c = getchar()) x = (x << 1) + (x << 3) + c - 48;
  if (neg) x *= -1;
}
int main() {
  string s;
  cin >> s;
  int k;
  cin >> k;
  int n = s.size();
  if (k > n)
    cout << "impossible";
  else {
    bool ch[26] = {false};
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      if (!ch[s[i] - 'a']) {
        cnt++;
        ch[s[i] - 'a'] = true;
      }
    }
    if (k - cnt >= 0)
      cout << k - cnt;
    else
      cout << "0";
  }
  return 0;
}
