main(a,b,c,d,e,f){scanf("%d.%d.%d\n%d.%d.%d",&a,&b,&c,&d,&e,&f);puts(a>d||(a==d&&b>e)||(a==d&&b==e&&c>f)||(a==d&&b==e&&c==f)?"YES":"NO");}