#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18 + 10;
const long long mod = 1e9 + 7;
const long long maxn = 1e5 + 10;
void solve() {
  string s;
  cin >> s;
  int k;
  cin >> k;
  int len = s.size();
  int l = 0, r = 0;
  for (int i = 0; i < len; i++) {
    if (s[i] == '?') {
      l++;
    } else if (s[i] == '*') {
      r++;
    }
  }
  string ans;
  if (len - l - r == k) {
    for (int i = 0; i < len; i++) {
      if (s[i] != '?' && s[i] != '*') ans += s[i];
    }
    cout << ans << endl;
  } else if (len - l - r > k && len - l - r - l - r <= k) {
    int tmp = len - l - r - k;
    for (int i = 0; i < len; i++) {
      if (s[i] != '?' && s[i] != '*') {
        if ((i + 1 < len) && (s[i + 1] == '?' || s[i + 1] == '*')) {
          if (tmp > 0) {
            tmp--;
            continue;
          }
        }
        ans += s[i];
      }
    }
    cout << ans << endl;
  } else if (len - l - r < k && r > 0) {
    int tmp = k - (len - l - r);
    for (int i = 0; i < len; i++) {
      if (s[i] != '?' && s[i] != '*') {
        if ((i + 1 < len) && s[i + 1] == '*') {
          if (tmp > 0) {
            for (int j = 0; j < tmp; j++) ans += s[i];
            tmp = 0;
          }
        }
        ans += s[i];
      }
    }
    cout << ans << endl;
  } else
    cout << "Impossible" << endl;
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve();
}
