#include <bits/stdc++.h>
using namespace std;
string b;
bool check[500];
int k, m;
int main() {
  cin >> b >> k;
  if (k > b.length()) {
    cout << "impossible" << endl;
    return 0;
  }
  for (int i = 0; i < b.length(); i++) {
    if (check[b[i]] == 1) continue;
    check[b[i]] = 1;
    m++;
  }
  cout << max(0, k - m) << endl;
}
