#include <bits/stdc++.h>
using namespace std;
int main() {
  set<char> myset;
  long long i, k;
  string s;
  cin >> s >> k;
  if (s.size() < k)
    cout << "impossible\n";
  else {
    for (i = 0; i < s.size(); i++) {
      myset.insert(s[i]);
    }
    if (myset.size() < k)
      cout << k - myset.size() << "\n";
    else
      cout << "0\n";
  }
  return 0;
}
