#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int num;
  cin >> num;
  if (num > s.length()) {
    cout << "impossible";
    return 0;
  }
  int kind = s.length();
  for (int i = 0; i < s.length(); i++) {
    for (int j = i + 1; j < s.length(); j++) {
      if (s[i] == s[j] && s[i] != '\0') {
        s[j] = '\0';
        kind--;
      }
    }
  }
  int ans = num - kind;
  if (kind >= num)
    cout << "0";
  else
    cout << ans;
  return 0;
}
