#include<stdio.h>
int main()
{
int a,b,c,d,e,f;
scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f);
if(d>=a)
{
if(d*86400+e*3600+f*60-a*86400-b*3600-c*60<=86400)
printf("Y e s");
else
printf("N o");
}
if(d<a)
{
if((d+7)*86400+e*3600+f*60-a*86400-b*3600-c*60<=86400)
{
printf("Y e s");
}
else
printf("N o");
}
return 0;
}