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