#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
long long int mod = 1000000007;
double PI = 3.14159265358979323846264338327950288;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
long long int arr[1000010] = {0};
int main() {
  long long int k, n, len;
  string s;
  cin >> s >> k;
  n = 0;
  len = (long long int)(s.size());
  for (long long int i = (0); i < (len); i++) {
    if (arr[s[i] - 'a'] == 0) n++;
    arr[s[i] - 'a']++;
  }
  if (len < k)
    printf("%s\n", "impossible");
  else {
    long long int ans = 0;
    if (n < k) {
      ans = k - n;
    }
    printf("%lld\n", ans);
  }
  return 0;
}
