#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  char str[1005];
  int freq[26] = {0};
  int k, n, i, c;
  cin >> str;
  cin >> k;
  n = strlen(str);
  for (i = 0; i < n; i++) {
    freq[str[i] - 'a'] += 1;
  }
  c = 0;
  for (i = 0; i < 26; i++) {
    if (freq[i] >= 1) c++;
  }
  if (c >= k) {
    cout << "0\n";
  } else {
    if (k > n)
      cout << "impossible\n";
    else {
      cout << k - c << endl;
    }
  }
}
