import sys input = sys.stdin.buffer.readline m, d, k = map(int, input().split()) used = [0] * (10) if m < 10: used[0] = 1 if d < 10: used[0] = 1 month31 = {1, 3, 5, 7, 10, 12} for i in range(7): dd = d + i if m in month31 and dd > 31: dd %= 31 if m not in month31 and dd > 30: dd %= 30 if dd < 10: used[0] = 1 for a in str(dd): used[int(a)] = 1 for a in str(m): used[int(a)] = 1 print("Yes" if sum(used) >= k else "No")