#include <bits/stdc++.h>
using namespace std;
int findMax(set<int> my_set) {
  int max_element;
  if (!my_set.empty()) max_element = *(my_set.rbegin());
  return max_element;
}
int count(int k) {
  int cnt = 0;
  for (int i(2); i * i <= k; i++) {
    if (k % i == 0) {
      cnt++;
      while (k % i == 0) {
        k /= i;
      }
    }
  }
  if (k > 1) cnt++;
  return pow(2, cnt);
}
int sum(int n) {
  int sum1 = 0, rem = 0;
  ;
  while (n > 0) {
    rem = n % 10;
    sum1 += rem;
    n /= 10;
  }
  return sum1;
}
long long is_Prime(long long n) {
  if (n == 2) return true;
  if (n < 2 || !(n & 1)) return false;
  for (long long i = 2; i * i <= n; i++)
    if (n % i == 0) return false;
  return true;
}
bool tall(long double x) {
  if (x >= 0) {
    long long sr = sqrt(x);
    return (sr * sr == x);
  }
  return false;
}
int cntset(int n) {
  long long cnt = 0;
  while (n > 0) {
    cnt++;
    n = n & (n - 1);
  }
  return cnt;
}
void solve() {
  string s;
  cin >> s;
  long long k;
  cin >> k;
  set<char> str;
  for (int i = 0; i < s.size(); i++) {
    str.insert(s[i]);
  }
  if (k > s.size()) {
    cout << "impossible" << endl;
  } else {
    if (k - str.size() < 0) {
      cout << 0 << endl;
    } else {
      cout << (k - str.size()) << endl;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}
