i=input p=print def g():return map(int,i().split('.')) for x,y in zip(g(),g()): if xy: p('YES') break else:p('YES')