m, d, k = map(int, input().split()) a = str(m) for i in range(7): t = d+i if m == 2: t = t % 28 if t == 0: t = 28 a += str((m+1) % 12) a += str(t).zfill(2) elif m in [4, 6, 9, 11]: t = t % 30 if t == 0: t = 30 a += str((m+1) % 12) a += str(t).zfill(2) else: t = t % 31 if t == 0: t = 31 a += str((m+1) % 12) a += str(t).zfill(2) if len(set(list(a))) < k: print("No") else: print("Yes")