#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main() {
int be[3];
int to[3];
for (int i = 0; i < 3; i++) {
scanf("%d", &be[i]);
}
for (int i = 0; i < 3; i++) {
scanf("%d", &to[i]);
}
if (be[0] > to[0]) {
if (to[0] + 7 - be[0] > 1) {
printf("N o");
}
else {
if (to[1] + 24 - be[1] < 24) {
printf("Y e s");
}
else if (to[1] + 24 - be[1] == 24) {
if (to[2] > be[2]) {
printf("N o");
}
else printf("Y e s");
}
else printf("N o");
}
}
else if (to[0] - be[0] > 1) {
printf("N o");
}
else if (to[0] - be[0] == 0) {
printf("Y e s");
}
else {
if (to[1] + 24 - be[1] < 24) {
printf("Y e s");
}
else if (to[1] + 24 - be[1] == 24) {
if (to[2] > be[2]) {
printf("N o");
}
else printf("Y e s");
}
else printf("N o");
}
}