#include <bits/stdc++.h>
using namespace std;
char message[201];
int ocurrences[201];
int main() {
  int n, i, k, candy_ocurrences, last_candy, snowflake_ocurreces,
      last_snowflake, eliminar;
  bool impossible;
  scanf("%s%d", message, &k);
  n = strlen(message);
  candy_ocurrences = snowflake_ocurreces = 0;
  impossible = false;
  memset(ocurrences, 0, sizeof ocurrences);
  for (i = 0; i < n; ++i) {
    ocurrences[i] = 1;
    if (message[i] == '*') {
      last_snowflake = i;
      ++snowflake_ocurreces;
    } else if (message[i] == '?') {
      last_candy = i;
      ++candy_ocurrences;
    }
  }
  if (n - candy_ocurrences - snowflake_ocurreces < k) {
    if (!snowflake_ocurreces)
      impossible = true;
    else
      ocurrences[last_snowflake] +=
          k - (n - candy_ocurrences - snowflake_ocurreces);
  } else if (n - candy_ocurrences - snowflake_ocurreces > k) {
    if (n - candy_ocurrences - snowflake_ocurreces - k >
        candy_ocurrences + snowflake_ocurreces)
      impossible = true;
    else {
      eliminar = n - candy_ocurrences - snowflake_ocurreces - k;
      for (i = 0; i < n && eliminar; ++i)
        if (message[i] == '*' || message[i] == '?') {
          ocurrences[i] = 0;
          --eliminar;
        }
    }
  }
  if (impossible)
    printf("Impossible");
  else {
    ocurrences[n] = 1;
    for (i = 0; i < n; ++i)
      if (message[i] != '*' && message[i] != '?')
        while (ocurrences[i + 1]--) printf("%c", message[i]);
  }
  return 0;
}
