#include <bits/stdc++.h>
const long long mod = 1e9 + 7;
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  string s;
  long long k, a = 0;
  cin >> s >> k;
  for (long long i = 0; i < s.size(); i++)
    if (s[i] == '*') a = i;
  if (s[a] == '*') {
    string ans = "";
    for (long long i = 0; i < a - 1; i++) {
      if (s[i + 1] == '?' || s[i + 1] == '*' || s[i] == '?' || s[i] == '*')
        continue;
      ans += s[i];
    }
    string ans2 = "";
    for (long long i = a + 1; i < s.size(); i++) {
      if (i + 1 < s.size())
        if (s[i + 1] == '?' || s[i + 1] == '*') continue;
      if (s[i] == '?' || s[i] == '*') continue;
      ans2 += s[i];
    }
    while (ans.size() + ans2.size() < k) ans += s[a - 1];
    if (ans.size() + ans2.size() > k) {
      cout << "Impossible" << endl;
      return 0;
    }
    cout << ans << ans2 << endl;
    return 0;
  }
  a = 0;
  for (long long i = 0; i < s.size(); i++)
    if (s[i] == '?') a++;
  if (s.size() - 2 * a > k || s.size() - a < k) {
    cout << "Impossible" << endl;
    return 0;
  }
  long long x = s.size() - a - k;
  string ans = "";
  s += 'A';
  for (long long i = 0; i < s.size() - 1; i++) {
    if (s[i + 1] == '?') {
      if (x <= 0 && s[x] != '?') {
        ans += s[i];
      }
      x--;
      continue;
    }
    if (s[i] != '?') ans += s[i];
  }
  cout << ans;
  return 0;
}
