M = list(map(int, input().split("."))) N = list(map(int, input().split("."))) if M[0] > N[0]: print("YES") elif M[0] == N[0] and M[1] > N[1]: print("YES") elif M[0] == N[0] and M[1] == N[1] and M[2] >= N[2]: print("YES") else: print("NO")