#include <bits/stdc++.h>
using namespace std;
int main() {
  int b[26], c, d = 0;
  for (int i = 0; i < 26; i++) {
    b[i] = 0;
  }
  string a;
  cin >> a;
  cin >> c;
  if (a.length() < c) {
    cout << "impossible";
    return 0;
  }
  for (int i = 0; i < a.length(); i++) {
    b[a[i] - 97]++;
    if (b[a[i] - 97] == 1) {
      d++;
    }
  }
  if (c >= d) {
    cout << c - d;
  } else {
    cout << "0";
  }
}
