#include<stdio.h>
int main(void){
int w1,h1,m1,w2,h2,m2;
scanf("%d %d %d",&w1,&h1,&m1);
scanf("%d %d %d",&w2,&h2,&m2);
if(w2<w1){
w2+=7;
if((w2-w1==1 && h2<h1) || (w2-w1==1 && h2==h1 && m2<=m1) || w2==w1){
printf("Y e s\n");
}
else printf("N o\n");
}
else{
if((w2-w1==1 && h2<h1) || (w2-w1==1 && h2==h1 && m2<=m1) || w2==w1){
printf("Y e s\n");
}
else printf("N o\n");
}
}