#include <stdio.h>
int main() {
int w1, h1, m1, r = 0;
int w2, h2, m2;
int t;
scanf("%d %d %d", &w1, &h1, &m1);
scanf("%d %d %d", &w2, &h2, &m2);
if(w1 == w2){
r = 1;
}else if(w2 - w1 == 1 || w2 - w1 == -6) {
t = (23 - h1) * 60;
t += 60 - m1;
t += 60 * h2;
t += m2;
if(t <= 24 * 60) {
r = 1;
//printf("2\n");
}
/*if(h == 24 && m2 < m1) {
r = 1;
}*/
}
if(r == 1) {
printf("Y e s\n");
}else {
printf("N o\n");
}
return 0;
}