#include <bits/stdc++.h>
using namespace std;
const int N = 210;
const int INF = 0x3f3f3f3f;
const double EPS = 1e-11;
int n, target, dp[N][N];
string str;
string ans[N][N];
std::vector<std::pair<char, int> > chs;
void add(const int idx, const string& s) {
  int len = s.length();
  if (!dp[idx][len]) dp[idx][len] = 1, ans[idx][len] = s;
}
void solve() {
  std::cin >> str >> target;
  n = str.length();
  for (int i = 0; i < n;) {
    if (i + 1 == n || (str[i + 1] != '*' && str[i + 1] != '?')) {
      chs.push_back(make_pair(str[i], 0));
      ++i;
    } else if (str[i + 1] == '?') {
      chs.push_back(make_pair(str[i], 1));
      i += 2;
    } else {
      chs.push_back(make_pair(str[i], 2));
      i += 2;
    }
  }
  int m = chs.size();
  memset(dp, 0, sizeof(dp));
  if (chs.front().second == 0) {
    dp[0][1] = 1;
    ans[0][1] = string(1, chs.front().first);
  } else if (chs.front().second == 1) {
    dp[0][0] = 1;
    dp[0][1] = 1;
    ans[0][1] = string(1, chs.front().first);
  } else {
    for (int i = 0; i <= target; i++) {
      dp[0][i] = 1;
      if (i) ans[0][i] = string(i, chs.front().first);
    }
  }
  for (int i = 1; i < m; ++i) {
    char ch = chs[i].first;
    int type = chs[i].second;
    for (int j = 0; j <= target; ++j)
      if (dp[i - 1][j]) {
        string tmp = ans[i - 1][j];
        if (type == 0) {
          tmp += string(1, ch);
          add(i, tmp);
        } else if (type == 1) {
          add(i, tmp);
          tmp += string(1, ch);
          add(i, tmp);
        } else {
          add(i, tmp);
          for (int k = 1; j + k <= target; ++k) {
            tmp += string(1, ch);
            add(i, tmp);
          }
        }
      }
  }
  if (!dp[m - 1][target])
    std::cout << "Impossible" << std::endl;
  else
    std::cout << ans[m - 1][target] << std::endl;
}
int main() {
  solve();
  return 0;
}
