#include <bits/stdc++.h>
using namespace std;
int main(void) {
  string s;
  int k;
  cin >> s >> k;
  if (k > s.size()) {
    cout << "impossible";
    return 0;
  }
  map<char, int> m;
  map<char, int>::iterator it;
  for (size_t i = 0; i < s.size(); i++) {
    m[s[i]]++;
  }
  int d(0), nd(0);
  for (it = m.begin(); it != m.end(); it++) {
    if (it->second != 1)
      nd++;
    else
      d++;
  }
  if (k < nd + d)
    cout << "0";
  else
    cout << k - (nd + d);
  return 0;
}
