#include <bits/stdc++.h>
using namespace std;
int main() {
  string message;
  int k, letter_count = 0, candy_count = 0, flake_count = 0, i;
  cin >> message >> k;
  int m = m = message.length();
  for (i = 0; i < m; i++) {
    if (message[i] == 42)
      flake_count++;
    else if (message[i] == 63)
      candy_count++;
    else
      letter_count++;
  }
  if (k == letter_count) {
    for (i = 0; i < m; i++) {
      if (message[i] != '*' && message[i] != '?') cout << message[i];
    }
  } else if (k > letter_count) {
    if (flake_count != 0) {
      int rem = k - letter_count;
      for (i = 0; i < m; i++) {
        if (rem != 0 && message[i + 1] == '*') {
          cout << message[i];
          for (int j = 0; j < rem; j++) cout << message[i];
          rem = 0;
        } else if (message[i] != '*' && message[i] != '?')
          cout << message[i];
      }
    } else
      cout << "Impossible";
  } else {
    if (letter_count - k == flake_count + candy_count) {
      for (i = 0; i < m; i++) {
        if (message[i + 1] == '*' || message[i + 1] == '?')
          i++;
        else
          cout << message[i];
      }
    } else if (letter_count - k > flake_count + candy_count) {
      cout << "Impossible";
    } else {
      int rem = letter_count - k;
      for (i = 0; i < m; i++) {
        if (rem != 0 && (message[i + 1] == '*' || message[i + 1] == '?')) {
          rem--;
          i++;
        } else if (message[i] != '*' && message[i] != '?')
          cout << message[i];
      }
    }
  }
}
