https://codeforces.com/contest/1099/problem/C
/*
*@Author: STZG
*@Language: C++
*/
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
//#define DEBUG
#define RI register int
using namespace std;
typedef long long ll;
//typedef __int128 lll;
const int N=100000+10;
const int MOD=1e9+7;
const double PI = acos(-1.0);
const double EXP = 1E-8;
const int INF = 0x3f3f3f3f;
int t,n,m,k,q,ans;
int a[N];
string str;
char s[N];
int main()
{
#ifdef DEBUG
freopen("input.in", "r", stdin);
//freopen("output.out", "w", stdout);
#endif
cin>>str;
scanf("%d",&k);
int len=str.size();
int cnt=0;
int x=0,y=0;
for(int i=0;i<len;i++){
if(str[i]!='?'&&str[i]!='*'){
s[++cnt]=str[i];
}else if(str[i]=='?'){
a[cnt]=1;
x++;
}else {
a[cnt]=2;
y++;
}
}
s[cnt+1]='\0';
if(x==0&&y==0&&cnt!=k){
cout << "Impossible" << endl;
return 0;
}
if(cnt==k){
printf("%s\n",s+1);
return 0;
}
if(cnt-x-y>k){
cout << "Impossible" << endl;
return 0;
}
if(y==0&&cnt<k){
cout << "Impossible" << endl;
return 0;
}
if(y==0||cnt>k){
t=cnt-k;
for(int i=1;i<=cnt;i++){
if(a[i]!=0&&t>0){
t--;continue;
}
printf("%c",s[i]);
}
printf("\n");
}else{
t=1;
for(int i=1;i<=cnt;i++){
if(a[i]==2&&t){
for(int j=cnt;j<=k;j++)
printf("%c",s[i]);
t=0;
continue;
}
printf("%c",s[i]);
}
printf("\n");
}
//cout << "Hello world!" << endl;
return 0;
}