from datetime import date, timedelta m, d, k = map(int, input().split()) ok = [False for _ in range(10)] def f(x: int): for _ in range(2): ok[x%10] = True x = x//10 dt = date(2022, m, d) for i in range(7): d = dt+ timedelta(i) f(d.month) f(d.day) if sum(ok) >= k: print("YES") else: print("NO")