#include <bits/stdc++.h>
using namespace std;
int main() {
  int k, len = 0, c = 0, sf = 0;
  string s;
  cin >> s >> k;
  for (char ch : s) {
    if (ch == '*')
      sf++;
    else if (ch == '?')
      c++;
    else
      len++;
  }
  if (len < k && sf == 0) {
    cout << "Impossible";
    return 0;
  }
  if (len - sf - c > k) {
    cout << "Impossible";
    return 0;
  }
  if (len == k) {
    for (char ch : s)
      if (ch != '*' && ch != '?') cout << ch;
    return 0;
  }
  string ans = "";
  if (len > k) {
    k = len - k;
    for (auto ch : s) {
      if ((ch == '*' || ch == '?')) {
        if (k && !ans.empty()) ans.pop_back(), k--;
      } else
        ans.push_back(ch);
    }
    cout << ans << endl;
  } else {
    k = k - len;
    for (int i = 0; i < s.length(); i++) {
      char ch = s[i];
      if (ch == '*') {
        while (k > 0 && i) {
          cout << s[i - 1];
          k--;
        }
      } else if (ch != '?')
        cout << ch;
    }
  }
}
