#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main() {
int day1, hour1, min1;
int day2, hour2, min2;
scanf("%d %d %d",&day1, &hour1, &min1);
scanf("%d %d %d",&day2, &hour2, &min2);
if (day1 == day2) {
printf("Y e s");
} else if (day1 == day2 - 1 || (day1 == 7)&&(day2 == 1)) {
if (hour2 < hour1 ) {
printf("Y e s");
} else if (hour2 == hour1) {
if(min2 <= min1)
printf("Y e s");
else
printf("N o");
} else {
printf("N o");
}
} else {
printf("N o");
}
return 0;
}