#include<stdio.h>
#include<string.h>
#include<ctype.h>
int main(void)
{
int x1,h1,m1,x2,h2,m2;
int k=1,m0,h0;
scanf("%d %d %d",&x1,&h1,&m1);
scanf("%d %d %d",&x2,&h2,&m2);
if(x2-x1>2||(x2-x1>-6&&x2-x1<0))
k=0;
else if(x2-x1==1||x2-x1==-6){
if(h2-h1>0)
k=0;
else if(h2==h1&&m2>m1){
k=0;
}
}
else if(x2==x1)
k=1;
if(k==1){
// if(h0*3600+m0<=24*3600||x2==x1)
printf("Y e s");
}
else
printf("N o");
return 0;
}