#include <bits/stdc++.h>
using namespace std;
int main() {
  char s[10005];
  int a[30], sum, k, len;
  while (scanf("%s", s + 1) == 1) {
    sum = 0;
    scanf("%d", &k);
    memset(a, 0, sizeof(a));
    len = strlen(s + 1);
    if (len < k) {
      printf("impossible\n");
      continue;
    }
    for (int i = 1; i <= len; i++) {
      a[s[i] - 'a' + 1]++;
    }
    for (int i = 1; i <= 26; i++) {
      if (a[i]) {
        sum++;
      }
    }
    if (sum >= k)
      printf("0\n");
    else
      printf("%d\n", k - sum);
    memset(s, 0, sizeof(s));
  }
}
