#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const long long mod = 1000000007;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  int k;
  cin >> s >> k;
  int n = s.size();
  int l = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] != '?' && s[i] != '*') l++;
  }
  int r = l - k;
  string e = "";
  for (int i = 0; i < n;) {
    if (i != n - 1 && s[i + 1] == '?') {
      if (r > 0)
        i += 2, r--;
      else {
        e += s[i];
        i += 2;
      }
    } else if (i != n - 1 && s[i + 1] == '*') {
      if (r > 0)
        i += 2, r--;
      else if (r == 0)
        e += s[i], i += 2;
      else {
        r--;
        while (r != 0) {
          e += s[i];
          r++;
        }
        i += 2;
      }
    } else {
      e += s[i];
      i++;
    }
  }
  if (r == 0 && e.size() == k)
    cout << e << "\n";
  else
    cout << "Impossible\n";
}
