#include <bits/stdc++.h>
using namespace std;
string s;
int k, n, ned, sum;
int main() {
  cin >> s;
  cin >> k;
  int len = s.length();
  int flag = 0;
  for (int i = 0; i < len; i++) {
    if (s[i] == '*' || s[i] == '?') {
      sum++;
      if (s[i] == '*') flag++;
    } else
      n++;
  }
  if (n - sum > k) {
    printf("Impossible");
    return 0;
  }
  ned = k - (n - sum);
  if (ned > sum && flag == 0) {
    printf("Impossible");
    return 0;
  }
  for (int i = 0; i < len; i++) {
    if (s[i + 1] == '?') {
      if (ned > 0) printf("%c", s[i]), ned--;
    } else if (s[i + 1] == '*') {
      while (ned > 0) printf("%c", s[i]), ned--;
    } else if (s[i] != '*' && s[i] != '?')
      printf("%c", s[i]);
  }
}
