a=list(map(int,input().split('.'))) b=list(map(int,input().split('.'))) ans='YES' for i in range(3): if a[i]