#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, a = "";
  vector<int> sfLocs, cLocs;
  int k;
  int candy = 0, sf = 0;
  cin >> s >> k;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == '*') {
      sf++;
      sfLocs.push_back(i);
    } else if (s[i] == '?') {
      candy++;
      cLocs.push_back(i);
    } else
      a += s[i];
  }
  int actualLength = s.length() - sf - candy;
  if ((actualLength - candy - sf) > k) {
    cout << "Impossible";
    return 0;
  }
  if (actualLength == k) {
    cout << a;
    return 0;
  }
  if (actualLength < k) {
    if (sf) {
      a = "";
      for (int i = 0; i < sfLocs[0]; i++) {
        if (s[i] == '*' || s[i] == '?')
          ;
        else
          a += s[i];
      }
      while (actualLength != k) {
        a += s[sfLocs[0] - 1];
        actualLength++;
      }
      for (int i = sfLocs[0] + 1; i < s.length(); i++) {
        if (s[i] == '*' || s[i] == '?')
          ;
        else
          a += s[i];
      }
      cout << a;
      return 0;
    } else {
      cout << "Impossible";
      return 0;
    }
  }
  if (actualLength > k && (actualLength - candy - sf) <= k) {
    int j = 0;
    while (actualLength != k) {
      if (j == cLocs.size()) break;
      s[cLocs[j] - 1] = '_';
      actualLength--;
      j++;
    }
    j = 0;
    while (actualLength != k) {
      if (j == sfLocs.size()) break;
      s[sfLocs[j] - 1] = '_';
      actualLength--;
      j++;
    }
    a = "";
    for (int i = 0; i < s.length(); i++) {
      if (s[i] == '*' || s[i] == '?' || s[i] == '_')
        ;
      else
        a += s[i];
    }
    cout << a;
    return 0;
  }
  return 0;
}
