#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  string s;
  cin >> s;
  long long k;
  cin >> k;
  long long a[26];
  for (long long i = 0; i < 26; i++) {
    a[i] = 0;
  }
  for (long long i = 0; i < s.size(); i++) {
    a[(long long)(s[i] - 'a')]++;
  }
  long long t = 0;
  for (long long i = 0; i < 26; i++) {
    if (a[i] != 0) {
      t++;
    } else {
      a[i] = 100000000;
    }
  }
  sort(a, a + 26);
  if (k > s.size()) {
    cout << "impossible" << endl;
  } else if (k - t < 0) {
    cout << 0 << endl;
  } else {
    cout << k - t << endl;
  }
  return 0;
}
