def get(): return list(map(int, input().split("."))) old_ver = get() ver1 = get() print("YNEOS"[old_ver