char a[9];i;main(b){gets(a-2);for(;(b=getchar()-10)&&i-9;a[i]=0)for(i=-3;++i<9&&a[i]-b+10;);i=!puts(i-8?"YES":"NO");}