M, D, K = map(int, input().split()) days = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] seen = set() for _ in range(7): for d in divmod(M, 10): seen.add(d) for d in divmod(D, 10): seen.add(d) D += 1 if D > days[M]: M = M % 12 + 1 D = 1 print("Yes" if len(seen) >= K else "No")