#include <bits/stdc++.h>
using namespace std;
char s[205];
int n;
int main() {
  scanf("%s", s);
  scanf("%d", &n);
  int len = strlen(s);
  int snow = 0, cany = 0;
  for (int i = 0; i < len; i++) {
    if (s[i] == '*')
      snow++;
    else if (s[i] == '?')
      cany++;
  }
  int rea = len - snow - cany;
  if (rea == n) {
    for (int i = 0; i < len; i++) {
      if (s[i] != '*' && s[i] != '?') printf("%c", s[i]);
    }
    printf("\n");
  } else if (rea < n) {
    if (snow > 0) {
      int num = n - rea, flag = 0;
      for (int i = 0; i < len; i++) {
        if (s[i] != '*' && s[i] != '?') printf("%c", s[i]);
        if (s[i] == '*' && flag == 0) {
          for (int j = 0; j < num; j++) printf("%c", s[i - 1]);
          flag = 1;
        }
      }
      printf("\n");
    } else {
      printf("Impossible\n");
    }
  } else {
    int num = rea - n;
    if (snow + cany < num) {
      printf("Impossible\n");
    } else {
      for (int i = 0; i < len; i++) {
        if (num && (s[i + 1] == '*' || s[i + 1] == '?')) {
          num--;
        } else if (s[i] == '*' || s[i] == '?')
          continue;
        else {
          printf("%c", s[i]);
        }
      }
      printf("\n");
    }
  }
  return 0;
}
