#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9 + 7;
const int N = 2e5 + 10;
pair<int, int> v[N];
int main() {
  string str;
  cin >> str;
  int k;
  cin >> k;
  int maxv = 0;
  int minv = 0;
  for (int i = 0; i < str.length(); i++) {
    if (isalpha(str[i]))
      v[i] = {1, 1};
    else if (str[i] == '?')
      v[i - 1] = {0, 1};
    else
      v[i - 1] = {0, 200};
  }
  for (int i = 0; i < str.length(); i++) {
    minv += v[i].first;
    maxv += v[i].second;
  }
  if (k < minv || k > maxv) puts("Impossible"), exit(0);
  k -= minv;
  for (int i = 0; i < str.length(); i++) {
    if (v[i].first == 1) {
      putchar(str[i]);
      continue;
    }
    int o = min(v[i].second, k);
    k -= o;
    while (o--) putchar(str[i]);
  }
  return 0;
}
