#include <stdio.h>
#include <math.h>
int main()
{
int total1=0,total2=0;
int y1,m1,d1;
int y2,m2,d2;
total2=86400;
//printf("%d\n",total2);
scanf("%d %d %d",&y1,&m1,&d1);
scanf("%d %d %d",&y2,&m2,&d2);
if(y1<y2)
{
total1=(y2-y1-1)*3600+(24-m1-1)*3600+m2*3600+(60-d1)*60+d2*60;
// printf("%d\n",total1);
if(total1>total2)
printf("N o");
else
printf("Y e s");
}
else if(y1>y2)
{
total1=(7-y1)*86400+(24-m1-1)*3600+(60-d1)*60;
total1+=y2*86400+m2*3600+d2*60-86400;
// printf("%d\n",total1);
if(total1>total2)
printf("N o");
else
printf("Y e s");
}
else
{
printf("Y e s");
}
return 0;
}