#include <bits/stdc++.h>
using namespace std;
int main() {
  string x, temp = "";
  cin >> x;
  int n, cnt_a = 0, cnt_b = 0;
  cin >> n;
  int len = x.size();
  for (int i = 0; i < len; i++) {
    if (x[i] != '?' && x[i] != '*') temp.push_back(x[i]);
    if (x[i] == '?') cnt_a++;
    if (x[i] == '*') cnt_b++;
  }
  int now = temp.size();
  int max_remove = cnt_a + cnt_b;
  int ans = 0;
  if (n < now - max_remove) ans = -1;
  if (cnt_b == 0) {
    if (n > now) ans = -1;
  }
  string fans = "";
  if (n == now) fans = temp;
  if (n > now) {
    int lagbe = n - now;
    bool hoise = false;
    for (int i = 0; i < x.size(); i++) {
      if (x[i] != '?' && x[i] != '*') fans.push_back(x[i]);
      if (x[i + 1] == '*' && hoise == false) {
        hoise = true;
        for (int j = 1; j <= lagbe; j++) fans.push_back(x[i]);
      }
    }
  }
  if (n < now) {
    int lagbe = now - n;
    for (int i = 0; i < x.size(); i++) {
      if ((x[i + 1] == '?' || x[i + 1] == '*') && lagbe > 0) {
        lagbe--;
        continue;
      }
      if (x[i] != '?' && x[i] != '*') fans.push_back(x[i]);
    }
  }
  if (ans == -1)
    cout << "Impossible" << endl;
  else
    cout << fans << endl;
  return 0;
}
