#include <bits/stdc++.h>
using namespace std;
string f0(string s) {
  string res = "";
  int i;
  for (i = 0; i < s.size(); i++)
    if (s[i] != '*' && s[i] != '?') res = res + s[i];
  return res;
}
void f1(string s) {
  string res = "";
  int i;
  for (i = 0; i < s.size(); i++)
    if (s[i] != '*' && s[i] != '?') res = res + s[i];
  cout << res << endl;
}
void f2(string s, int k) {
  string res = "";
  int i, j;
  for (i = s.size() - 1; i >= 0 && k; i--)
    if (s[i] == '*' || s[i] == '?') {
      k--;
      i--;
    } else
      res = s[i] + res;
  for (i; i >= 0; i--) res = s[i] + res;
  f1(res);
}
void f3(string s, int k) {
  string res = "";
  int i;
  for (i = 0; i < s.size(); i++)
    if (s[i] == '*') {
      break;
    }
  int j, aux, t;
  aux = k;
  string resfin = "";
  for (j = 0; j < s.size(); j++) {
    if (j == i) {
      for (t = 0; t < aux; t++) resfin = resfin + s[i - 1];
    } else
      resfin = resfin + s[j];
  }
  f1(resfin);
}
int main() {
  string s;
  cin >> s;
  int ca = 0, cb = 0;
  int c, i;
  for (i = 0; i < s.size(); i++) {
    if (s[i] == '*') ca++;
    if (s[i] == '?') cb++;
  }
  int k, t;
  scanf("%d", &k);
  if (k < s.size() - 2 * (ca + cb))
    printf("Impossible\n");
  else {
    if (k > s.size() - ca - cb && ca == 0)
      printf("Impossible\n");
    else if (k == s.size() - ca - cb)
      f1(s);
    else {
      if (k < s.size() - ca - cb)
        f2(s, (s.size() - ca - cb) - k);
      else
        f3(s, k - (s.size() - ca - cb));
    }
  }
  return 0;
}
