#include <bits/stdc++.h>
using namespace std;
const int N = 5e5;
int main() {
  string s;
  int k;
  cin >> s >> k;
  int l1 = s.length();
  int l = 0;
  int snow = 0;
  int candy = 0;
  for (int i = 0; i < l1; i++) {
    if (s[i] == '*' && i != 0) {
      snow++;
    } else if (s[i] == '?' && i != 0) {
      candy++;
    } else {
      l++;
    }
  }
  int add = k - l;
  int db = k - l;
  if (db < 0) {
    db = 0;
  }
  string str = "";
  if (k < l - (snow + candy) || (snow == 0 && k > l)) {
    cout << "Impossible" << endl;
  } else {
    for (int i = 0; i < l1; i++) {
      if (s[i] == '*' || s[i] == '?') {
      } else if (s[i + 1] == '*' && db) {
        str = str + string(1, s[i]);
        for (int j = 0; j < db; j++) {
          str = str + string(1, s[i]);
        }
        db = 0;
      } else if (add > 0 && (s[i + 1] == '*' || s[i + 1] == '?')) {
        str = str + s[i];
        add--;
      } else if (add < 0 && (s[i + 1] == '*' || s[i + 1] == '?')) {
        add++;
      } else {
        str = str + string(1, s[i]);
      }
    }
    cout << str << endl;
  }
}
