#include <bits/stdc++.h>
using namespace std;
int main() {
  string a;
  cin >> a;
  long long n = 0, star = 0, que = 0;
  long long r;
  cin >> r;
  for (long long i = 0; i < a.size(); i++) {
    if (a[i] != '*' && a[i] != '?')
      n++;
    else if (a[i] == '*' && i > 0)
      star++;
    else if (a[i] == '?' && i > 0)
      que++;
  }
  if (n == r) {
    for (long long i = 0; i < a.size(); i++)
      if (a[i] != '*' && a[i] != '?') cout << a[i];
    return 0;
  }
  if (r < n) {
    long long temp = n - r;
    if (temp > star + que) {
      cout << "Impossible";
      return 0;
    } else {
      for (long long i = 0; i < a.size(); i++) {
        long long check = 0;
        if (i < a.size() - 1 && (a[i + 1] == '*' || a[i + 1] == '?'))
          if (temp) {
            temp--;
            check = 1;
          }
        if (a[i] != '*' && a[i] != '?') {
          if (check == 0) cout << a[i];
        }
      }
    }
    return 0;
  }
  if (r > n) {
    if (star == 0) {
      cout << "Impossible";
      return 0;
    } else {
      long long temp = r - n, check = 0;
      for (long long i = 0; i < a.size(); i++) {
        if (a[i] != '*' && a[i] != '?') cout << a[i];
        if (a[i] == '*' && check == 0) {
          check = 1;
          while (temp--) cout << a[i - 1];
        }
      }
    }
  }
}
