#include <bits/stdc++.h>
using namespace std;
long long sum_mod(long long a, long long b) { return (a + b) % 1000000007; }
long long subtract_mod(long long a, long long b) {
  return (a % 1000000007 - b % 1000000007 + 1000000007) % 1000000007;
}
long long multiply_mod(long long a, long long b) {
  return (a % 1000000007 * b % 1000000007) % 1000000007;
}
long long modInverse(long long x, long long y) {
  long long res = 1;
  x = x % 1000000007;
  while (y > 0) {
    if (y & 1) res = (res * x) % 1000000007;
    y = y >> 1;
    x = (x * x) % 1000000007;
  }
  return res;
}
long long divide_mod(long long a, long long b) {
  return (a * modInverse(b, 1000000007 - 2)) % 1000000007;
}
long long gcd(long long a, long long b) {
  while (b) swap(a %= b, b);
  return a;
}
int main() {
  string s;
  cin >> s;
  long long k;
  cin >> k;
  string res = "";
  for (int i = 0; i < s.length(); ++i) {
    if (s[i] == '?' || s[i] == '*')
      res.pop_back();
    else
      res += s[i];
  }
  int idx = 0;
  for (int i = 0; i < s.length() - 1; ++i) {
    if (s[i] == '*' || s[i] == '?') continue;
    if (s[i + 1] == '?' && res.length() < k)
      res.insert(idx++, 1, s[i]);
    else if (s[i + 1] == '*') {
      while (res.length() < k) res.insert(idx++, 1, s[i]);
    } else
      idx++;
  }
  if (res.length() == k)
    cout << res << endl;
  else
    cout << "Impossible" << endl;
}
