#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string a;
  cin >> a;
  int n;
  cin >> n;
  bool b = 0;
  int p = 0;
  for (int i = 0; i < a.size(); i++)
    if (a[i] == '*') b = 1, p = i;
  int x = 0;
  for (int i = 0; i < a.size(); i++) {
    if (a[i] == '*' || a[i] == '?') x++;
  }
  if (a.size() - x * 2 <= n && (n <= a.size() - x || b)) {
    if (n > a.size() - x && b) {
      for (int i = 0; i < a.size(); i++) {
        if (i == p) {
          for (int j = 0; j < n - a.size() + x; j++) cout << a[p - 1];
        }
        if ('a' <= a[i] && a[i] <= 'z') cout << a[i];
      }
      cout << '\n';
      return 0;
    }
    int c = a.size() - x;
    string b;
    for (int i = 0; i < a.size(); i++) {
      if (!('a' <= a[i] && a[i] <= 'z')) {
        if (c > n) b.resize(b.size() - 1), c--;
      } else
        b += a[i];
    }
    cout << b << '\n';
  } else
    cout << "Impossible\n";
}
