#include <bits/stdc++.h>
using namespace std;
int sta[26], n;
char ch[1005];
int main() {
  for (int i = 0; i < 26; i++) sta[i] = 0;
  scanf("%s", ch + 1);
  scanf("%d", &n);
  int p = 1, cnt = 0;
  while (ch[p]) {
    if (sta[ch[p] - '0'] == 0) cnt++;
    sta[ch[p] - '0'] = 1;
    p++;
  }
  p--;
  if (26 < n || p < n)
    printf("impossible\n");
  else if (cnt >= n)
    printf("0\n");
  else
    printf("%d\n", n - cnt);
  return 0;
}
