#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  while (cin >> str) {
    int i, j, k, l, m, n;
    cin >> k;
    l = str.length();
    if (l < k) {
      cout << "impossible" << endl;
      continue;
    }
    map<char, int> mp;
    m = 0;
    j = 0;
    for (i = 0; i < l; i++) {
      mp[str[i]]++;
      if (mp[str[i]] == 1)
        m++;
      else
        j++;
    }
    if (m >= k)
      cout << 0 << endl;
    else
      cout << k - m << endl;
  }
  return 0;
}
