#include <bits/stdc++.h>
using namespace std;
bool comp(pair<int, int> x1, pair<int, int> x2) { return x1.first < x2.first; }
int main() {
  string s;
  cin >> s;
  int k;
  cin >> k;
  int c = 0;
  int sn = 0;
  int w = 0;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == '?') c++;
    if (s[i] == '*') sn++;
  }
  int a = s.length() - 2 * c - 2 * sn;
  if (a <= k) {
    if (sn > 0) {
      string ss = "";
      for (int i = 0; i < s.length(); i++) {
        if (s[i] == '*') {
          for (int j = 0; j < k - a; j++) ss += s[i - 1];
          s = s.substr(0, i) + ss + s.substr(i, s.length() - i);
          break;
        }
      }
      string ans = "";
      for (int i = 0; i < s.length() - 1; i++) {
        if (s[i] != '?' && s[i] != '*') {
          if (s[i + 1] != '?' && s[i + 1] != '*') {
            ans += s[i];
          }
        }
      }
      if (s[s.length() - 1] != '?' && s[s.length() - 1] != '*') {
        ans += s[s.length() - 1];
      }
      cout << ans << "\n";
    } else {
      int x = s.length() - c;
      if (x >= k) {
        int cnt = 0;
        string ans = "";
        for (int i = 0; i < s.length() - 1; i++) {
          if ((s[i + 1] == '?') && cnt < x - k) {
            cnt++;
          } else {
            ans += s[i];
          }
        }
        ans += s[s.length() - 1];
        string aa = "";
        for (int i = 0; i < ans.length(); i++)
          if (ans[i] != '?') aa += ans[i];
        cout << aa << "\n";
      } else {
        cout << "Impossible"
             << "\n";
      }
    }
  } else {
    cout << "Impossible"
         << "\n";
  }
  return 0;
}
