#include <bits/stdc++.h>
using namespace std;
char s[1005];
int x[300];
int myabs(int a) {
  if (a < 0) return -a;
  return a;
}
int main() {
  cin >> s;
  int n;
  cin >> n;
  int l = strlen(s);
  if (n > l) {
    cout << "impossible" << endl;
  } else {
    int i;
    int num = 0;
    for (i = 0; i < l; i++) {
      if (x[s[i] - 'a'] == 0) {
        num++;
      }
      x[s[i] - 'a']++;
    }
    if (n >= num) {
      cout << n - num << endl;
    } else
      cout << 0 << endl;
  }
}
