a,b,c=map(int,input().split()) if a>1988 and c>7 or a>2020 and b>5 and c>31:print("YES") else:print("NO")