#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
signed main() {
  string s;
  cin >> s;
  long long int k;
  cin >> k;
  if (s.size() < k) {
    cout << "impossible\n";
    return 0;
  }
  sort(s.begin(), s.end());
  s.erase(unique(s.begin(), s.end()), s.end());
  cout << max(0ll, (long long int)(k - s.size())) << "\n";
  return 0;
}
