#include <bits/stdc++.h>
using namespace std;
string s, res;
int k;
int main() {
  cin >> s;
  cin >> k;
  int cnt = 0, len = 0;
  int fir = -1;
  for (int i = 0; i < (int)s.length(); i++) {
    if (s[i] != '?' && s[i] != '*') {
      cnt++;
      len++;
    }
    if (s[i] == '?' || s[i] == '*') cnt--;
    if (s[i] == '*') fir = i;
  }
  if (cnt > k || (len < k && fir == -1)) {
    cout << "Impossible";
    return 0;
  } else {
    if (fir == -1) {
      int t = len - k;
      for (int i = 0; i < (int)s.length(); i++) {
        if (s[i] != '?') res += s[i];
        if (s[i] == '?' && t > 0) {
          res.pop_back();
          t--;
        }
      }
      cout << res;
      return 0;
    }
    int t = k - cnt;
    for (int i = 0; i < (int)s.length(); i++) {
      if (s[i] != '?' && s[i] != '*') res += s[i];
      if (s[i] == '?' || s[i] == '*') res.pop_back();
      if (i == fir) {
        char l = s[i - 1];
        while (t--) res += l;
      }
    }
  }
  cout << res;
  return 0;
}
