#include <bits/stdc++.h>
using namespace std;
const int oo = 1e9;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int k;
  cin >> k;
  int n = (int)s.size(), a = 0, b = 0;
  for (int i = 0; i < n; i++) {
    a += (s[i] == '*');
    b += (s[i] == '?');
  }
  if (n - 2 * (a + b) > k || (k > (n - (a + b)) && a == 0)) {
    cout << "Impossible" << '\n';
    return 0;
  }
  vector<int> del(n);
  int m = n - (a + b), last = n;
  for (int i = 0; i < n; i++) {
    if (i + 1 < n && s[i + 1] == '?' || s[i + 1] == '*') {
      if (m > k) del[i] = 1, m--;
      if (s[i + 1] == '*') last = i;
      i++;
    }
  }
  for (int i = 0; i < last; i++)
    if (isalpha(s[i]) && !del[i]) cout << s[i];
  if (last < n && !del[last])
    for (int i = 0; i <= k - m; i++) cout << s[last];
  for (int i = last + 1; i < n; i++)
    if (isalpha(s[i]) && !del[i]) cout << s[i];
  cout << '\n';
  return 0;
}
