#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, letters = 0, snow = 0, candies = 0;
  string s, ans = "";
  cin >> s;
  cin >> k;
  n = s.size();
  for (int i = 0; i < (int)n; i++) {
    if (s[i] == '?')
      candies += 1;
    else if (s[i] == '*')
      snow += 1;
    else
      letters += 1;
  }
  if ((letters - (candies + snow) > k) || (k > letters && snow == 0)) {
    cout << "Impossible\n";
    return 0;
  }
  if (letters > k) {
    for (int i = 0; i < (int)n; i++) {
      if (i + 1 < n && (s[i + 1] == '?' || s[i + 1] == '*') && letters != k) {
        letters--;
        continue;
      } else if (s[i] != '?' && s[i] != '*')
        ans += s[i];
    }
  } else if (letters == k) {
    for (int i = 0; i < (int)n; i++) {
      if (s[i] != '?' && s[i] != '*') ans += s[i];
    }
  } else {
    for (int i = 0; i < (int)n; i++) {
      if (i + 1 < n && s[i + 1] == '*' && letters != k) {
        ans += s[i];
        while (letters != k) {
          ans += s[i];
          letters += 1;
        }
      } else if (s[i] != '?' && s[i] != '*')
        ans += s[i];
    }
  }
  cout << ans << "\n";
}
