// Try Codeforces
// author: Leonardone @ NEETSDKASU
import std.algorithm  : sort, sum;
import std.array      : split;
import std.conv       : to;
import std.stdio      : readln, writeln;
import std.string     : chomp;

auto gets() { return readln.chomp; }
auto getV(T)() { return readln.chomp.to!T; }

void main() {
    auto s = gets;
    auto k = getV!int;
    
    if (s.length < k) {
        writeln("impossible");
        return;
    }
    
    int[char] tb;
    
    foreach (ch; s) {
        tb[ch]++;
    }
    
    if (tb.length >= k) {
        writeln(0);
        return;
    }
    
    if (tb.length < k) {
        writeln(k - tb.length);
        return;
    }
    
    writeln(tb.values.sort[0..$-k].sum);
    
}