#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool read(T &x) {
  int c = getchar();
  int sgn = 1;
  while (~c && c<'0' | c> '9') {
    if (c == '-') sgn = -1;
    c = getchar();
  }
  for (x = 0; ~c && '0' <= c && c <= '9'; c = getchar()) x = x * 10 + c - '0';
  x *= sgn;
  return ~c;
}
const long long N = 2005;
long long ara[N];
int main() {
  string str;
  cin >> str;
  long long k;
  cin >> k;
  long long candy = 0, snow = 0;
  for (long long i = 0; str[i]; ++i) {
    candy += (str[i] == '?');
    snow += (str[i] == '*');
  }
  long long sz = str.size();
  if (!snow) {
    if (sz - candy < k)
      puts("Impossible");
    else if ((sz - candy) - candy > k)
      puts("Impossible");
    else {
      long long ase = sz - candy - k;
      for (long long i = 0; str[i]; ++i) {
        if (str[i] == '?' && ase) str[i - 1] = '?', --ase;
      }
      for (long long i = 0; str[i]; ++i) {
        if (str[i] != '?') cout << str[i];
      }
    }
  } else {
    if (sz - 2 * (candy + snow) > k)
      puts("Impossible");
    else if (sz - (candy + snow) == k) {
      for (long long i = 0; str[i]; ++i) {
        if (str[i] != '?' && str[i] != '*') cout << str[i];
      }
    } else {
      if (sz - (candy + snow) > k) {
        long long ase = sz - candy - snow - k;
        for (long long i = 0; str[i]; ++i) {
          if ((str[i] == '?' || str[i] == '*') && ase) str[i - 1] = '?', --ase;
        }
        for (long long i = 0; str[i]; ++i) {
          if (str[i] != '?' && str[i] != '*') cout << str[i];
        }
      } else {
        long long need = k - (sz - candy - snow);
        for (long long i = 0; str[i]; ++i) {
          if (str[i] == '*') {
            ara[i - 1] = need;
            break;
          }
        }
        for (long long i = 0; str[i]; ++i) {
          if (str[i] != '?' && str[i] != '*') cout << str[i];
          while (ara[i]) cout << str[i], --ara[i];
        }
      }
    }
  }
}
