#include<stdio.h>
int main(void)
{
int time[2][3];
int i,j;
for(i=0;i<2;i++)
{
for(j=0;j<3;j++)
{
scanf("%d",&time[i][j]);
}
}
if(time[0][0]==time[1][0])
printf("Y e s\n");
else if((time[1][0]-time[0][0])==1||(time[0][0]==7&&time[1][0]==1))
{
if((((23-time[0][1])+time[1][1])*60+(60-time[0][2]+time[1][2]))<=(60*24))
printf("Y e s\n");
else
printf("N o\n");
}
else
printf("N o\n");
return 0;
}