#include <bits/stdc++.h>
using namespace std;
int main() {
  int snow = 0, can = 0, i, l, min, max, k, e, flag, n = 0;
  string s;
  cin >> s;
  cin >> k;
  l = s.length();
  for (i = 0; s[i] != '\0'; i++) {
    if (s[i] == '*')
      snow++;
    else if (s[i] == '?')
      can++;
  }
  min = l - (2 * can) - (2 * snow);
  if (snow == 0)
    max = l - can - snow;
  else
    max = 200;
  if (min <= k && k <= max) {
    if (l == 2) {
      if (s[1] == '*') {
        while (k--) cout << s[0];
      } else if (s[1] == '?') {
        if (k == 1)
          cout << s[0];
        else
          cout << "Impossible";
      }
      return 0;
    }
    if (snow > 0) {
      flag = 1;
      e = k - min;
      for (i = 0; s[i + 1] != '\0'; i++) {
        if (s[i + 1] != '?' && s[i + 1] != '*' && s[i] != '?' && s[i] != '*')
          cout << s[i];
        if (s[i + 1] == '*' && flag) {
          while (e--) cout << s[i];
          flag = 0;
        }
      }
      if (s[i] != '?' && s[i] != '*') cout << s[i];
    } else {
      e = k - min;
      n = 0;
      for (i = 0; s[i + 1] != '\0'; i++) {
        if (s[i] != '?') {
          if (s[i + 1] == '?') n++;
          if (n <= e) {
            cout << s[i];
          } else if (s[i + 1] != '?')
            cout << s[i];
        }
      }
      if (s[i] != '?') cout << s[i];
    }
  } else
    cout << "Impossible";
  return 0;
}
