#include<cstdio>
#include<cstring>
bool cnt[30];
int main()
{
    char t;
    int ans=0;   //重复字符数
    int num=0;   //字符长度
    memset(cnt,false,sizeof(cnt));
    while(1)
    {
        t=getchar();
        if(t=='
')
            break;
        else if(cnt[(int)(t-'a')])
            ans++;
        else
            cnt[(int)(t-'a')]=true;
        num++;
    }
    int k;
    scanf("%d",&k);
    if(num<k)
        printf("impossible
");
    else if((num-ans)>k)
        printf("0
");
    else
        printf("%d",k-num+ans);
    return 0;
}