#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, c = 0;
  ;
  string s;
  cin >> s;
  cin >> n;
  sort(s.begin(), s.end());
  if (s.size() < n) {
    cout << "impossible" << endl;
    return 0;
  }
  for (i = 0; i < s.size(); i++) {
    if (s[i] != s[i + 1]) {
      c++;
    }
  }
  if (c <= n) {
    cout << n - c << endl;
  } else {
    cout << 0 << endl;
  }
}
