#include <bits/stdc++.h>
using namespace std;
vector<string> c;
bool Msg(int n, int k, int index, int length) {
  for (int i = index; i < n; i++) {
    if (c[i] == "?") {
      if (length > k) {
        c[i - 1] = "";
        c[i] = "";
        length--;
      } else {
        c[i] = "";
      }
      return Msg(n, k, i + 1, length);
    } else if (c[i] == "*") {
      if (length > k) {
        c[i - 1] = "";
        c[i] = "";
        length--;
      } else if (length < k) {
        c[i] = "";
        for (int j = 0; j < k - length; j++) c[i] = c[i] + c[i - 1];
        length = k;
      } else
        c[i] = "";
      return Msg(n, k, i + 1, length);
    }
  }
  return length == k;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> s;
  int k, n = s.length(), cont = 0;
  cin >> k;
  for (int i = 0; i < n; i++) {
    string temp = "";
    temp = temp + s[i];
    c.push_back(temp);
    if (s[i] == '?')
      cont++;
    else if (s[i] == '*')
      cont++;
  }
  if (n - 2 * cont > k) {
    cout << "Impossible" << '\n';
    return 0;
  }
  bool ok = Msg(n, k, 0, n - cont);
  if (ok) {
    for (int i = 0; i < n; i++) cout << c[i];
    cout << '\n';
  } else
    cout << "Impossible" << '\n';
  return 0;
}
