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