#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int k;
  cin >> k;
  int s1 = s.size();
  map<int, int> m, m1;
  int cnt = 0, cnt1 = 0, flag = 0, snow = 0;
  for (int i = 0; i < s1; i++) {
    if (s[i + 1] == '*') {
      flag = 1;
      snow++;
    } else if (s[i + 1] == '?') {
      cnt++;
    } else {
      cnt1++;
    }
  }
  if (cnt1 < k && flag == 1) {
    int need = k - cnt1;
    for (int i = 0; i < s1 - 1; i++) {
      if (s[i + 1] == '*' && (s[i] >= 'a' && s[i] <= 'z') && flag == 1) {
        cout << s[i];
        while (need != 0) {
          cout << s[i];
          need--;
        }
        flag = 0;
        continue;
      }
      if (s[i] >= 'a' && s[i] <= 'z') cout << s[i];
    }
    if (s[s1 - 1] >= 'a' && s[s1 - 1] <= 'z') cout << s[s1 - 1];
    cout << endl;
  } else if ((cnt1) > k) {
    int del = cnt1 - k;
    if (del <= cnt + snow) {
      for (int i = 0; i < s1 - 1; i++) {
        if (s[i] >= 'a' && s[i] <= 'z' &&
            (s[i + 1] == '?' || s[i + 1] == '*') && del != 0) {
          del--;
          continue;
        }
        if (s[i] >= 'a' && s[i] <= 'z') {
          cout << s[i];
        }
      }
      if (s[s1 - 1] >= 'a' && s[s1 - 1] <= 'z') cout << s[s1 - 1];
      cout << endl;
    } else {
      cout << "Impossible" << endl;
    }
  } else if (cnt1 == k) {
    for (int i = 0; i < s1; i++) {
      if (s[i] >= 'a' && s[i] <= 'z') {
        cout << s[i];
      }
    }
    cout << endl;
  } else {
    cout << "Impossible" << endl;
  }
}
