#include <bits/stdc++.h>
using namespace std;
int main(int argc, char* argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int k;
  string str;
  cin >> str;
  cin >> k;
  int temp[50];
  memset(temp, 0, sizeof(temp));
  int count = 0;
  for (int i = 0; i < str.size(); ++i) {
    if (temp[(int)(str[i] - 'a')] == 0) {
      count++;
      temp[str[i] - 'a'] = 1;
    }
  }
  if (count >= k) {
    cout << "0" << endl;
  } else if (k > (int)str.size()) {
    cout << "impossible" << endl;
  } else {
    cout << k - count << endl;
  }
  return 0;
}
