#include <bits/stdc++.h>
int n;
bool a[36];
char s[1010];
signed main() {
  scanf("%s%d", s, &n);
  int l(strlen(s));
  if (n > l) return puts("impossible"), 0;
  for (register int i(0); i < l; i++) n -= !a[s[i] - 96], a[s[i] - 96] = 1;
  return printf("%d\n", n < 0 ? 0 : n), 0;
}
