M,D,K=map(int,input().split()) def next_day(M,D): if (M,D)==(12,31): return 1,1 D+=1 if (31,28,31,30,31,30,31,31,30,31,30,31)[M-1]=K: ans="Yes" else: ans="No" print(ans)