#include <bits/stdc++.h>
using namespace std;
bool checkperfectsquare(int n) {
  if (ceil((double)sqrt(n)) == floor((double)sqrt(n))) {
    return true;
  }
  return false;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string s;
  cin >> s;
  long long int k;
  cin >> k;
  long long int n = s.length();
  map<int, int> mp;
  for (long long int i = 0; i < n; i++) {
    mp[s[i]]++;
  }
  if (k > s.length()) {
    cout << "impossible";
  } else if (mp.size() >= k) {
    cout << "0";
  } else {
    cout << k - mp.size();
  }
}
