#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int c[26] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
               0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
  string s;
  int k;
  cin >> s >> k;
  int l = s.size();
  for (int i = 0; i < l; ++i) ++c[s[i] - 'a'];
  int count_0 = 0;
  for (int i = 0; i < 26; ++i)
    if (!c[i]) ++count_0;
  int num = 0;
  int diff = 0;
  for (int i = 0; i < 26; ++i)
    if (c[i]) ++diff;
  int i = 0;
  while (i < 26 && count_0 && diff < k) {
    if (c[i] > 1) {
      --c[i];
      --count_0;
      ++diff;
      ++num;
      continue;
    }
    ++i;
  }
  if (diff >= k)
    cout << num;
  else
    cout << "impossible";
  return 0;
}
