#include <bits/stdc++.h>
using namespace std;
const string alf = "abcdefghijklmnopqrstuvwxyz";
const int hashP = 239017;
const int N = 1e5 + 10;
const int MOD = 1e9 + 7;
const int MOD2 = 998244353;
const int INF = 1e9;
const long long INF2 = 1e18;
template <typename T>
bool umn(T &a, T b) {
  return (a > b ? (a = b, 1) : 0);
}
template <typename T>
bool umx(T &a, T b) {
  return (a < b ? (a = b, 1) : 0);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> s;
  long long k;
  cin >> k;
  long long cnt = 0, n = s.size();
  for (int i = 0; i < n; i++) {
    if (s[i] >= 'a' && s[i] <= 'z') cnt++;
  }
  if (cnt == k) {
    for (auto now : s) {
      if (now >= 'a' && now <= 'z') cout << now;
    }
    return 0;
  }
  if (cnt < k) {
    for (int i = 0; i < n; i++) {
      if (s[i] == '*') {
        while (cnt < k) {
          s.insert(s.begin() + i, s[i - 1]);
          cnt++;
        }
        for (auto now : s) {
          if (now >= 'a' && now <= 'z') {
            cout << now;
          }
        }
        return 0;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (cnt == k) break;
    if (s[i] == '?' || s[i] == '*') {
      s[i - 1] = '-';
      cnt--;
    }
  }
  if (cnt != k) {
    cout << "Impossible";
    return 0;
  }
  for (auto now : s) {
    if (now >= 'a' && now <= 'z') {
      cout << now;
    }
  }
  return 0;
}
