#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
using namespace std;
inline int read() {
  int r = 0;
  char c = getchar();
  while (c < '0' || c > '9') {
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    r = r * 10 + c - '0';
    c = getchar();
  }
  return r;
}
inline long long readll() {
  long long r = 0;
  char c = getchar();
  while (c < '0' || c > '9') {
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    r = r * 10 + c - '0';
    c = getchar();
  }
  return r;
}
inline long long qpow(long long a, long long b, long long mod) {
  long long res = 1;
  while (b) {
    if (b & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return res;
}
inline long long gcd(long long a, long long b) {
  while (b ^= a ^= b ^= a %= b)
    ;
  return a;
}
const double eps = 1e-8;
const long long LLINF = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int MAXN = 1e5;
const int MAXM = 1e5;
string s;
bool vis[300];
int main() {
  int k, l;
  cin >> s >> k;
  l = s.length();
  int re1 = 0, re2 = 0;
  for (int i = 0; i < l; i++) {
    if (s[i] == '?') re1++;
    if (s[i] == '*') re2++;
  }
  l -= (re1 + re2);
  memset(vis, 0, sizeof(vis));
  if (l - re1 - re2 <= k && k <= l) {
    int kk = 0;
    for (int i = 0; i < s.length(); i++) {
      if (kk >= l - k) break;
      if (s[i] == '?' || s[i] == '*') {
        vis[i - 1] = 1;
        kk++;
        if (kk == l - k) break;
      }
    }
    for (int i = 0; i < s.length(); i++) {
      if (!vis[i] && s[i] != '*' && s[i] != '?') cout << s[i];
    }
    puts("");
    return 0;
  }
  if (l <= k) {
    bool flag = 0;
    for (int i = 0; i < s.length(); i++) {
      if (s[i] == '*') {
        flag = 1;
        vis[i - 1] = 1;
        break;
      }
    }
    if (flag || (l == k)) {
      for (int i = 0; i < s.length(); i++) {
        if (vis[i]) {
          for (int j = 1; j <= k - l + 1; j++) cout << s[i];
        }
        if (!vis[i] && s[i] != '?' && s[i] != '*') cout << s[i];
      }
      puts("");
      return 0;
    }
    puts("Impossible");
    return 0;
  }
  puts("Impossible");
  return 0;
}
