fl = input()
sl = input()
numofel = fl[0]
int(numofel)
slist = sl.split(" ")
firstnum = slist[0]
lastnum = slist[-1]
int(firstnum)
int(lastnum)
if firstnum == numofel or lastnum == numofel:
  print("Yes")
else:
  print("No")