#include <bits/stdc++.h>
using namespace std;
int seg_size(int n) { return (1 << (int)(ceil(log2(n)) + 1)) - 1; }
const long long mod = (long long)1e+9 + 7;
const long long inf = (long long)1e+18 + 5;
int main() {
  ios_base::sync_with_stdio(false);
  cout.tie(NULL);
  string s;
  cin >> s;
  int i;
  int l = s.length();
  int k;
  cin >> k;
  int c = 0;
  int star = 0, que = 0;
  for (i = 0; i < l; i++) {
    if (s[i] == '*')
      star++;
    else if (s[i] == '?')
      que++;
    else
      c++;
  }
  if (c <= k) {
    if (c < k && star == 0) {
      cout << "Impossible";
      return 0;
    }
    string s1;
    for (i = 0; i < l; i++) {
      while (s[i] == '*' && c < k) {
        s1.push_back(s[i - 1]);
        c++;
      }
      if (s[i] != '*' && s[i] != '?') s1.push_back(s[i]);
    }
    cout << s1;
  } else {
    string s1;
    for (i = 0; i < l; i++) {
      if ((s[i] == '*' || s[i] == '?') && k < c) {
        s1.pop_back();
        c--;
      } else if (s[i] != '*' && s[i] != '?')
        s1.push_back(s[i]);
    }
    if (s1.length() != k) {
      cout << "Impossible";
      return 0;
    } else
      cout << s1;
  }
  return 0;
}
