#include<stdio.h>
int main(void)
{
int t,h,m;
int T,H,M;
scanf("%d%d%d", &t, &h, &m);
scanf("%d%d%d", &T, &H, &M);
if((t-T) == 0)
printf("Y e s\n");
else if((t-T) == -1 || (t-T) == 6) {
if((h-H)>0)
printf("Y e s\n");
else if((h-H) == 0) {
if((m-M)>=0)
printf("Y e s\n");
else if((m-M)<0)
printf("N o\n");
}
else if((h-H) < 0)
printf("N o\n");
}
else
printf("N o\n");
return 0;
}