#include <bits/stdc++.h>
using namespace std;
using namespace std;
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
struct compare {
  bool operator()(const std::string& first, const std::string& second) {
    return first.size() < second.size();
  }
};
int main() {
  string s;
  cin >> s;
  int k;
  cin >> k;
  int n = s.size();
  int curr = 0;
  for (int i = 0; i < n; i++)
    if (s[i] != '?' && s[i] != '*') curr++;
  string ans = "";
  for (int i = n - 1; i > -1; i--) {
    if (s[i] == '?') {
      if (curr > k) {
        curr--;
        i--;
      }
    } else if (s[i] == '*') {
      if (curr > k) {
        curr--;
        i--;
      } else if (curr < k) {
        while (curr < k) {
          ans += s[i - 1];
          curr++;
        }
      }
    } else {
      ans += s[i];
    }
  }
  n = ans.size();
  if (k != n) {
    cout << "Impossible" << endl;
    return 0;
  }
  for (int i = n - 1; i > -1; i--) cout << ans[i];
  return 0;
}
