#include<math.h>
#include<stdlib.h>
#include<string.h>
#include<stdio.h>
int main()
{
int day1,day2;
int hour1,hour2;
int min1,min2;
int t=0;
scanf("%d %d %d",&day1,&hour1,&min1);
scanf("%d %d %d",&day2,&hour2,&min2);
if(day1>day2){
day1=day1-7;
}
t=(day2-day1)*24*60+(hour2-hour1)*60+(min2-min1);
if(t<=1440){
printf("Y e s");
} else {
printf("N o");
}
return 0;
}