#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  string a;
  cin >> a;
  int needed;
  cin >> needed;
  int star = 0;
  int q = 0;
  int provided = 0;
  for (int i = 0; i < a.length(); i++) {
    if (a[i] == '*') {
      star++;
    } else if (a[i] == '?') {
      q++;
    } else {
      provided++;
    }
  }
  int var;
  int removed;
  if (provided >= needed) {
    removed = provided - needed;
    if (q + star >= removed) {
      for (int i = 0; i < a.size(); i++) {
        if (a[i] != '?' && a[i] != '*') {
          if (a[i + 1] == '?' || a[i + 1] == '*') {
            if (removed > 0) {
              removed--;
              continue;
            } else {
              cout << a[i];
            }
          } else {
            cout << a[i];
          }
        }
      }
    } else {
      cout << "Impossible";
    }
  } else {
    if (star > 0) {
      for (int i = 0; i < a.size(); i++) {
        if (a[i] != '*' && a[i] != '?') {
          if (a[i + 1] == '*') {
            while (needed > provided) {
              cout << a[i];
              needed--;
            }
            if (needed == provided) {
              cout << a[i];
            }
          } else {
            cout << a[i];
          }
        }
      }
    } else {
      cout << "Impossible";
    }
  }
  return 0;
}
