#include <bits/stdc++.h>
using namespace std;
int vis[200];
char s[2000 + 5];
int K;
int main() {
  while (~scanf("%s", s + 1)) {
    memset(vis, 0, sizeof(vis));
    scanf("%d", &K);
    int ans = 0;
    int n = strlen(s + 1);
    for (int i = 1; i <= n; i++) {
      if (!vis[s[i]]) {
        ans++;
        vis[s[i]] = 1;
      }
    }
    if (K <= n)
      printf("%d\n", max(0, K - ans));
    else
      printf("impossible\n");
  }
}
