#include<stdio.h>
#include<math.h>
int main(){
int a,b,c,t1,t2,t;
scanf("%d%d%d",&a,&b,&c);
t1 = a*60*24+b*60+c;
scanf("%d%d%d",&a,&b,&c);
t2= a*60*24 +b*60+c;
t= t2 - t1;
if((t>=0&&t <= 24*60)||(-t>=6*60*24&&-t<=7*60*24))printf("Y e s\n");
else printf("N o\n");
return 0;
}