N = abs(int(input()))
pr = 1
while N > 0:
pr *= (N % 10)
N //= 10
if 99 < pr < 1000:
print("YES")
else:
print("NO")
N = abs(int(input()))
pr = 1
while N > 0:
pr *= (N % 10)
N //= 10
if 99 < pr < 1000:
print("YES")
else:
print("NO")