#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int k;
  cin >> k;
  set<char> st;
  int a = s.length();
  if (a < k) {
    cout << "impossible" << endl;
    return 0;
  }
  for (int i = 0; i < a; i++) {
    st.insert(s[i]);
  }
  int b = st.size();
  int c = k - b;
  if (c <= 0) {
    cout << "0" << endl;
  } else {
    cout << c << endl;
  }
}
