#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int MAXN = 3e5 + 10;
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
long long gcd(long long a, long long b) {
  long long c;
  while (a != 0) {
    c = a;
    a = b % a;
    b = c;
  }
  return b;
};
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
set<char> st;
int c[30];
int main() {
  string s;
  int k;
  cin >> s >> k;
  for (int i = 0; i < s.size(); ++i) {
    st.insert(s[i]);
  }
  int len = st.size();
  if (s.size() < k) {
    cout << "impossible" << endl;
    return 0;
  }
  cout << max(k - len, 0) << endl;
}
