#include <bits/stdc++.h>
using namespace std;
long long k, n, difnum, i, a[27];
string s;
int main() {
  cin >> s >> k;
  if (k > s.length()) {
    cout << "impossible";
    return 0;
  }
  for (int i = 0; i < s.length(); i++) {
    if (!a[s[i] - 96]) difnum++;
    a[s[i] - 96] = 1;
  }
  if (k <= difnum)
    cout << 0;
  else
    cout << k - difnum;
}
