#include <bits/stdc++.h>
using namespace std;
int main() {
  map<int, int> mp;
  int n;
  int k;
  string s;
  cin >> s;
  n = s.size();
  cin >> k;
  for (auto x : s) {
    mp[x]++;
  }
  int p = mp.size();
  if (k > n)
    cout << "impossible" << endl;
  else if (k < p)
    cout << 0 << endl;
  else
    cout << k - p << endl;
}
