#include <bits/stdc++.h>
using namespace std;
int main() {
  int k, t = 0, b = 0, i, w = 0;
  string s;
  cin >> s;
  cin >> k;
  for (i = 0; i < s.size(); i++) {
    if (s[i] == '?') {
      t++;
    } else if (s[i] == '*') {
      b++;
    } else {
      w++;
    }
  }
  if (k > s.size() - t - b) {
    int x;
    x = k - (s.size() - t - b);
    if (b > 0) {
      for (i = 0; i < s.size(); i++) {
        if (s[i] != '?' && s[i] != '*') {
          cout << s[i];
        } else if (s[i] == '*') {
          while (x != 0) {
            cout << s[i - 1];
            x--;
          }
        }
      }
    } else {
      cout << "Impossible";
    }
  } else {
    int x = w - k;
    if (k < s.size() - (2 * (s.size() - w))) {
      cout << "Impossible";
    } else {
      for (i = 0; i < s.size(); i++) {
        if (s[i + 1] != '?' && s[i + 1] != '*') {
          if (s[i] != '?' && s[i] != '*') {
            cout << s[i];
          }
        } else if (s[i + 1] == '?' || s[i + 1] == '*') {
          if (x > 0) {
            x--;
          } else {
            cout << s[i];
          }
        }
      }
    }
  }
}
