#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e3 + 10;
long long n, k;
char s[MAXN];
int num[33];
int main() {
  while (cin >> s) {
    cin >> k;
    int len = strlen(s);
    if (len < k) {
      cout << "impossible" << endl;
    } else {
      memset(num, 0, sizeof num);
      for (int i = 0; i < len; ++i) {
        num[s[i] - 'a']++;
      }
      long long ans = 0;
      for (int i = 0; i < 26; ++i) {
        if (num[i]) ++ans;
      }
      if (ans <= k)
        cout << k - ans << endl;
      else
        cout << 0 << endl;
    }
  }
  return 0;
}
