#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, s1, ans = "";
  int n, i, c = 0, rem = 0, rep = 0, st = 0, need = 0;
  cin >> s >> n;
  for (i = 0; i < s.length(); i++) {
    if (s[i] != '*' && s[i] != '?') {
      c++;
    }
    if (s[i] == '*' || s[i] == '?') {
      rem++;
    }
    if (s[i] == '*') {
      rep++;
    }
  }
  if (c == n) {
    for (i = 0; i < s.length(); i++) {
      if (s[i] != '*' && s[i] != '?') {
        ans += s[i];
      }
    }
    cout << ans;
    return 0;
  }
  if (c > n) {
    if ((c - rem) > n) {
      cout << "Impossible" << endl;
      return 0;
    } else {
      while (c != n) {
        c--;
        st++;
      }
      while (st != 0) {
        for (i = 0; i < s.length(); i++) {
          if (s[i] == '*' || s[i] == '?') {
            s.erase(s.begin() + (i - 1));
            st--;
          }
          if (st == 0) {
            break;
          }
        }
      }
      for (i = 0; i < s.length(); i++) {
        if (s[i] != '*' && s[i] != '?') {
          ans += s[i];
        }
      }
      cout << ans;
      return 0;
    }
  }
  if (c < n) {
    if (rep > 0) {
      need = n - c;
      for (i = 0; i < s.length(); i++) {
        if (s[i] == '*') {
          while (need != 0) {
            s1 += s[i - 1];
            need--;
          }
        } else {
          s1 += s[i];
        }
      }
      for (i = 0; i < s1.length(); i++) {
        if (s1[i] != '*' && s1[i] != '?') {
          ans += s1[i];
        }
      }
      cout << ans << endl;
      return 0;
    } else {
      cout << "Impossible" << endl;
      return 0;
    }
  }
}
