#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:1024000000,1024000000")
long long mod = 1e9 + 7;
const long long INF = 1e18;
const double eps = 1e-6;
const int maxn = 3e5 + 5;
template <class T>
inline bool scan_d(T &ret) {
  char c;
  int sgn;
  if (c = getchar(), c == EOF) return 0;
  while (c != '-' && (c < '0' || c > '9')) c = getchar();
  sgn = (c == '-') ? -1 : 1;
  ret = (c == '-') ? 0 : (c - '0');
  while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c - '0');
  ret *= sgn;
  return 1;
}
inline void out(long long x) {
  if (x > 9) out(x / 10);
  putchar(x % 10 + '0');
}
int main() {
  string s;
  cin >> s;
  int n;
  cin >> n;
  if (n > 26 || n > s.size()) {
    puts("impossible");
  } else {
    set<char> st;
    for (int i = 0; i < s.size(); i++) st.insert(s[i]);
    int ans = n - st.size();
    ans = max(ans, 0);
    printf("%d\n", ans);
  }
}
