#include<stdio.h>
#include<math.h>
int main(){
int day1,day2,hour1,hour2,min1,min2,k=1;
scanf("%d%d%d%d%d%d",&day1,&hour1,&min1,&day2,&hour2,&min2);
if(day2-day1>1)
k=0;
if(day2!=1&&day1!=7&&day2-day1<0)
k=0;
if(day2-day1==1||day2==1&&day1==7){
if(hour1<hour2)
k=0;
if(hour1=hour2){
if(min1<min2)
k=0;
}
}
if(k==1)
printf("Y e s\n");
if(k==0)
printf("N o\n");
}