program main
	implicit none
	character i*3,j*3
	read(*,*)i
	read(*,*)j
	if(i(1:1)==j(3:3).or.i(2:2)==j(2:2).or.j(1:1)==i(3:3))then
		write(*,"(a3)")"YES"
	else
		write(*,"(a2)")"NO"
	endif
end program main
