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