#include <stdio.h>
#include <math.h>
int main()
{
int day1,hour1,minute1;
int day2,hour2,minute2;
scanf("%d %d %d",&day1,&hour1,&minute1);
scanf("%d %d %d",&day2,&hour2,&minute2);
if(day1==day2){
printf("Y e s\n");}
else if((day2==day1+1)||(day1==7&&day2==1)){
if(hour2<hour1){
printf("Y e s\n");}
else if(hour2==hour1){
if(minute2<=minute1)
printf("Y e s\n");
else{printf("N o\n");}}
else{printf("N o\n");}}
else{printf("N o\n");}
}