#include <bits/stdc++.h>
using namespace std;
int main() {
  char arr[1002];
  int k, n, a, b, c, d = 0;
  scanf("%s", &arr);
  scanf("%d", &k);
  n = strlen(arr);
  if (k > n) {
    printf("impossible");
    return 0;
  }
  for (a = 1; a < n; a++) {
    c = 0;
    for (b = a - 1; b >= 0; b--) {
      if (arr[a] == arr[b]) c++;
    }
    if (c == 0) d++;
  }
  d = d + 1;
  if (k > d) printf("%d", k - d);
  if (k < d) printf("0");
  if (k == d) printf("0");
}
