#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j, d = 0, e = 0, f = 0;
  string s;
  vector<char> v;
  cin >> s >> n;
  for (i = 0; i < s.size(); i += 1) {
    if (s[i] != '*' && s[i] != '?')
      d += 1;
    else if (s[i] == '*')
      e += 1;
    else
      f += 1;
    v.push_back(s[i]);
  }
  if (d > n) {
    if (f + e >= d - n) {
      int count = d - n, temp = 0, i = 0;
      while (temp < count) {
        if (v[i] == '*' || v[i] == '?') {
          temp += 1;
          v.erase(v.begin() + i);
          v.erase(v.begin() + i - 1);
          i -= 1;
        }
        i += 1;
      }
      for (i = 0; i < v.size(); i += 1) {
        if (v[i] != '*' && v[i] != '?') cout << v[i];
      }
    } else
      cout << "Impossible";
  } else if (d == n) {
    for (i = 0; i < v.size(); i += 1) {
      if (v[i] != '*' && v[i] != '?') cout << v[i];
    }
  } else {
    if (e == 0)
      cout << "Impossible" << endl;
    else {
      int count = n - d;
      bool flag = true;
      for (i = 0; i < v.size(); i += 1) {
        if (v[i] != '*' && v[i] != '?')
          cout << v[i];
        else if (v[i] == '?')
          ;
        else {
          if (flag == true) {
            for (int j = 0; j < count; j += 1) cout << v[i - 1];
            flag = false;
          }
        }
      }
    }
  }
  cout << endl;
}
