#include char*s,*t,q[99],n;int main(){for(;~scanf("%s%s",s=q,t=q+16);n=!puts(*t|n?"NO":"YES"))for(;*s;*t%16-n%10||(n=*t&&!t++))n+=*s++%16;}