#include<stdio.h>
int main(){
int w1,h1,m1,w2,h2,m2;
long long total1,total2;
scanf("%d %d %d",&w1,&h1,&m1);
scanf("%d %d %d",&w2,&h2,&m2);
if(w1<=w2){
total1=(w1-1)*24*3600+h1*3600+m1*60;
total2=(w2-1)*24*3600+h2*3600+m2*60;
}
else{
total1=(w1-1)*24*3600+h1*3600+m1*60;
total2=(w2+7-1)*24*3600+h2*3600+m2*60;
}
if((total2-total1)<=(24*3600))
printf("Y e s");
else
printf("N o");
}