def No(): print("No") exit() p = input() c = 0 fin = 0 L = len(p) for j in range(L)[::-1]: i = int(p[j]) if c==0: if i == 6 or i == 7: fin = 1 c = 0 elif i == 2 or i == 3 or i == 4: if fin: No() c = 1 else: No() elif c==1: if i==1: if j==0: c = 0 break else: No() elif i == 7 or i == 8: fin = 1 c = 0 elif i == 3 or i == 4 or i == 5: if fin: No() c = 1 else: No() print("Yes" if c==0 else "No")