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