#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")
using namespace std;
const int MX = 1e9 + 1;
const int Imp = -1;
const int N = 1e6 + 5;
const int M = 1e6 + 5;
const long long INF = 1e18 + 1;
int n, k;
string s;
set<char> st;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  string s;
  cin >> s;
  int k;
  cin >> k;
  int n = s.size();
  if (n < k) {
    cout << "impossible";
  } else {
    for (int i = 0; i < n; ++i) st.insert(s[i]);
    int x = st.size();
    if (x > k)
      cout << 0;
    else
      cout << abs(x - k);
  }
}
