#include <stdio.h>
struct time{
int day;
int hour;
int min;
};
int main(){
struct time n[2];
int i;
for(i=0;i<2;i++){
scanf("%d%d%d",&n[i].day,&n[i].hour,&n[i].min);
}
int temp = 0;
if(n[0].day == n[1].day){
printf("Y e s");
}else if(n[0].day - n[1].day == -1 || n[0].day - n[1].day == 6){
if(n[1].hour-n[0].hour+24 <= 24 && n[1].min - n[0].min +60 <=60){
printf("Y e s");
}else {
printf("N o");
}
}else {
printf("N o");
}
}