def buhefa(s): if s[0]=='*': return 1 for i in range(len(s)-1): if s[i]=='*' and s[i+1]=='*': return 1 return 0
def quchong(exp): i=0 while i<len(exp)-2: if exp[i+1]=='*' and exp[i]==exp[i+2]: exp=exp[:i+2]+exp[i+3:] else: i+=1
def solve(s,exp): flag=0 if buhefa(exp): return 0 else: i,j=0,0 while i<len(s) and j<len(exp): if j<len(exp)-1 and exp[j+1]=='*': if exp[j]=='.': if j+2==len(exp): break else: j+=2 while i<len(s) and s[i]!=exp[j]: i+=1 i_bianli=i+1 while i_bianli<len(s): if solve(s[i_bianli:],exp[j:]): return 1 i_bianli+=1
else: while i<len(s) and s[i]!=exp[j]: i+=1 j+=2 else: if exp[j]==s[i] or exp[j]=='.': i+=1 j+=1 else: return 0 flag=1 break if flag==0: return 1
s=input() exp=input() flag=solve(s,exp) if flag: print('YES') else: print('NO')