#include <bits/stdc++.h>
using namespace std;
int arr[26];
int main() {
  string s;
  cin >> s;
  short k = 0;
  int c = 0;
  cin >> k;
  if (k > s.size()) {
    cout << "impossible";
    return 0;
  }
  for (int i = 0; i < s.size(); ++i) ++arr[s[i] - 'a'];
  for (int i = 0; i < 26; i++)
    if (arr[i] > 0) {
      ++c;
    }
  if (k <= c)
    cout << "0";
  else
    cout << k - c;
  return 0;
}
