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