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