#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  int k;
  cin >> s >> k;
  int opts = 0;
  bool any_klein = false;
  int letters = 0;
  for (const auto& c : s) {
    if (c == '*') {
      opts++;
      any_klein = true;
    } else if (c == '?') {
      opts++;
    } else {
      letters++;
    }
  }
  stringstream ss;
  auto pp = [&](char c) {
    if (c == '*') {
    } else if (c == '?') {
    } else {
      ss << c;
    }
  };
  if (letters == k) {
    for (const auto& c : s) {
      pp(c);
    }
    ss << endl;
  } else if (letters < k) {
    if (any_klein) {
      int rem = k - letters;
      bool done = false;
      int last = 0;
      for (int i = 0; i < s.size(); i++) {
        bool next_is_klein = i < s.size() - 1 && s[i + 1] == '*';
        pp(s[i]);
        if (next_is_klein) {
          if (!done) {
            while (rem--) pp(s[i]);
            done = true;
          }
        }
      }
      ss << endl;
    } else {
      ss << "Impossible" << endl;
    }
  } else {
    if (letters - k <= opts) {
      int rem = letters - k;
      int last = 0;
      for (int i = 0; i < s.size(); i++) {
        bool next_is_klein = i < s.size() - 1 && s[i + 1] == '*';
        bool next_is_opt =
            next_is_klein || (i < s.size() - 1 && s[i + 1] == '?');
        if (next_is_opt) {
          if (rem > 0) {
            rem--;
          } else {
            pp(s[i]);
          }
        } else {
          pp(s[i]);
        }
      }
      ss << endl;
    } else {
      ss << "Impossible" << endl;
    }
  }
  cout << ss.str();
  return 0;
}
