#include<stdio.h>
#include<string.h>
int main()
{
int xq,xs,fz,xq1,xs1,fz1,m;double sum;
scanf("%d %d %d %d %d %d",&xq,&xs,&fz,&xq1,&xs1,&fz1);
if(xq1<xq)m=xq1+7-xq;
else m=xq1-xq;
if(xq==xq1)printf("Y e s\n");
else if(m>1)printf("N o\n");
else if(m==1)
{
sum=(24-xs-(double)fz/60.0)+xs1+(double)fz1/60.0;
if(sum<=24)printf("Y e s\n");
else printf("N o\n");
}
}