#include <bits/stdc++.h>
using namespace std;
int main() {
  string ch;
  int k, i;
  cin >> ch;
  cin >> k;
  int n = ch.size();
  if (k > n)
    cout << "impossible" << endl;
  else {
    int count = 0;
    sort(ch.begin(), ch.end());
    for (i = 0; i < n; i++) {
      if (ch[i] != ch[i - 1]) count++;
    }
    if (count <= k)
      cout << k - count << endl;
    else
      cout << "0" << endl;
  }
  return 0;
}
