#include <bits/stdc++.h>
using namespace std;
string s;
int n, jum;
bool bol[50];
int main() {
  cin >> s >> n;
  for (int i = 0; i < s.length(); i++) {
    if (!bol[s[i] - 'a']) {
      jum++;
      bol[s[i] - 'a'] = true;
    }
  }
  int l = s.length();
  if (jum < n && l >= n)
    cout << n - jum << endl;
  else if (jum >= n)
    cout << "0" << endl;
  else if (l < n)
    cout << "impossible" << endl;
}
