#include <bits/stdc++.h>
using namespace std;
int l[26];
int main() {
  string s;
  cin >> s;
  int n;
  cin >> n;
  for (int i = 0; i < s.length(); i++) {
    l[s[i] - 97] += 1;
  }
  int u = 0;
  for (int i = 0; i < 26; i++) {
    if (l[i] != 0) {
      u++;
    }
  }
  if (n > s.length()) {
    cout << "impossible" << endl;
  } else if (u >= n) {
    cout << "0" << endl;
  } else {
    cout << n - u << endl;
  }
}
