#include<stdio.h>
int main(){
int d,h,m;
int d1,h1,m1;
scanf("%d %d %d",&d,&h,&m);
scanf("%d %d %d",&d1,&h1,&m1);
if(d1==d)
printf("Y e s\n");
else if((d1==d+1)||(d==7&&d1==1)){if(h1>h)
printf("N o\n");
if(h1<h)
printf("Y e s\n");
if(h1==h){
if(m1>m)
printf("N o\n");
else
printf("Y e s\n");
}}
else
printf("N o\n");
return 0;}