#include<stdio.h>
int main()
{
int week1,hour1,mi1,week2,hour2,mi2;
float s;
scanf("%d %d %d",&week1,&hour1,&mi1);
scanf("%d %d %d",&week2,&hour2,&mi2);
if((week2-week1)==0)
s=hour2-hour1+(mi2-mi1)/60.0;
else if((week2-week1)==1||(week2-week1)==-6)
s=24-hour1+hour2+(mi2-mi1)/60.0;
else
s=25;
if(s<=24)
printf("Y e s");
else
printf("N o");
return 0;
}