#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  string s;
  cin >> s;
  long long k;
  cin >> k;
  string ans;
  long long ok = 0, del = 0, l = 0, normal = 0;
  for (long long i = 0; i < s.size(); i++) {
    if (s[i] >= 'a' && s[i] <= 'z') {
      ok++;
    }
    if (s[i] == '*') {
      l = 1;
    }
    if (s[i] == '?') {
      normal++;
    }
  }
  if (ok < k) {
    if (l) {
      long long ost = k - ok;
      string ans;
      for (long long i = 0; i < s.size(); i++) {
        if (s[i] >= 'a' && s[i] <= 'z') {
          ans += s[i];
        } else if (s[i] == '*' && ost) {
          while (ost) {
            ans += s[i - 1];
            ost--;
          }
        }
      }
      cout << ans;
    } else {
      cout << "Impossible";
      exit(0);
    }
  } else {
    long long del = ok - k;
    string ans;
    for (long long i = 0; i < s.size(); i++) {
      if (s[i] == '?' || s[i] == '*') {
        continue;
      }
      if (s[i] >= 'a' && s[i] <= 'z' && i + 1 < s.size() &&
          (s[i + 1] == '?' || s[i + 1] == '*') && del) {
        del--;
      } else {
        ans += s[i];
      }
    }
    if (del == 0) {
      cout << ans;
    } else {
      cout << "Impossible";
      exit(0);
    }
  }
  return 0;
}
