li = list(input().strip().split())
for i in range(len(li)):
if li[i] == 'K':
li[i] = 13
elif li[i] == 'Q':
li[i] = 12
elif li[i] == 'J':
li[i] = 11
elif li[i] == 'A':
li[i] = 1
else:
li[i]=int(li[i])
ans = [[]]*6
ans[0] = li
for i in range(1,6):
for j in range(len(ans[i-1])):
ans[i].append(ans[i-1][j]+li[i])
ans[i].append(ans[i-1][j]-li[i])
ans[i].append(ans[i-1][j]*li[i])
ans[i].append(ans[i-1][j]//li[i])
flag = 0
for j in range(len(ans[5])):
if ans[5][j] == 42:
flag = 1
break
if flag == 1:
print("YES")
else:
print("NO")
输入例子: K 5 6 3 Q 4
输出:YES