#include <bits/stdc++.h>
using namespace std;
void solve() {
  string s, result;
  int i, candy = 0, snow = 0, alpha = 0, count = 0, k;
  cin >> s;
  cin >> k;
  int n = s.size();
  for (int j = 0; j < n; j++) {
    if (s[j] >= 'a' && s[j] <= 'z')
      alpha++;
    else if (s[j] == '?')
      candy++;
    else
      snow++;
  }
  int dec = snow + candy;
  int inc = snow;
  if (alpha >= k) {
    if (alpha - dec <= k) {
      count = alpha - k;
      for (i = 0; i < n - 1 && count; i++) {
        if (s[i + 1] == '?' || s[i + 1] == '*') {
          count--;
          i++;
        } else
          result += s[i];
      }
    } else {
      cout << "Impossible";
      return;
    }
  } else if (inc) {
    int count = k - alpha;
    for (i = 0; count; i++) {
      if (s[i] == '?') continue;
      if (s[i] == '*') {
        while (count) {
          result += s[i - 1];
          count--;
        }
      } else
        result += s[i];
    }
  } else {
    cout << "Impossible";
    return;
  }
  for (; result.size() < k; i++) {
    if (s[i] != '*' && s[i] != '?') result += s[i];
  }
  cout << result;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
}
