#include <bits/stdc++.h>
using namespace std;
const int maxn = 10000;
int main() {
  char c[maxn];
  int n;
  int flag;
  int a[26];
  while (cin >> c) {
    int ans = 0;
    memset(a, 0, sizeof(a));
    flag = 1;
    cin >> n;
    int len = strlen(c);
    if (n > len)
      flag = 0;
    else {
      for (int i = 0; i < len; i++) a[c[i] - 'a'] = 1;
      for (int i = 0; i < 26; i++) {
        if (a[i] == 1) ans++;
      }
      if (ans >= n)
        cout << "0" << endl;
      else
        cout << n - ans << endl;
    }
    if (flag == 0) cout << "impossible" << endl;
  }
  return 0;
}
