#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (a % b == 0)
    return b;
  else
    return gcd(b, a % b);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  vector<int> v(26, 0);
  int cnt = 0;
  string s;
  cin >> s;
  int k;
  cin >> k;
  for (int i = 0; i < s.length(); i++) {
    if (v[s[i] - 97] == 0) {
      cnt++;
      v[s[i] - 97] = 1;
    }
  }
  int n = s.length();
  if (cnt < k) {
    if (n - k >= 0)
      cout << k - cnt;
    else
      cout << "impossible";
  } else
    cout << 0;
  return 0;
}
