#include <bits/stdc++.h>
using namespace std;
vector<string> split(string s) {
  istringstream buf(s);
  istream_iterator<string> beg(buf), end;
  vector<string> list(beg, end);
  return list;
}
bool isvowel(char c) {
  string s = "aeiou";
  if (find(s.begin(), s.end(), c) != s.end()) return true;
  return false;
}
bool cmp(pair<int, int> &a, pair<int, int> &b) {
  return a.second > b.second || (a.second == b.second && a.first > b.first);
}
void solve() {
  string s;
  cin >> s;
  int k;
  cin >> k;
  int candy = 0;
  int snow = 0;
  int rest = 0;
  int n = s.size();
  for (auto c : s) {
    if (c == '*')
      snow++;
    else if (c == '?')
      candy++;
    else
      rest++;
  }
  if (snow == 0) {
    if (rest < k || k < rest - candy) {
      cout << "Impossible";
      return;
    }
    int extra = rest - k;
    int i = 0;
    while (extra > 0 && i < n - 1) {
      if (i + 1 < n && s[i + 1] == '?') s[i] = '?', extra--;
      i++;
    }
    for (auto c : s) {
      if (c != '?' && c != '*') cout << c;
    }
  } else {
    if (k < rest - candy - snow) {
      cout << "Impossible";
      return;
    }
    if (k < rest) {
      int extra = rest - k;
      int i = 0;
      while (extra > 0 && i < n - 1) {
        if (i + 1 < n && (s[i + 1] == '?' || s[i + 1] == '*'))
          s[i] = '?', extra--;
        i++;
      }
      for (auto c : s) {
        if (c != '?' && c != '*') cout << c;
      }
      return;
    } else {
      int extra = k - rest;
      int i = 0;
      string t;
      while (s[i] != '*') i++;
      int pos = i;
      for (int q = 0; q < extra; q++) {
        t.push_back(s[i - 1]);
      }
      for (int j = 0; j < i; j++) {
        if (s[j] != '?' && s[j] != '*') cout << s[j];
      }
      cout << t;
      for (int j = i; j < n; j++) {
        if (s[j] != '?' && s[j] != '*') cout << s[j];
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  for (int test_case = 1; test_case <= t; test_case++) {
    solve();
  }
  return 0;
}
