A0,B0,C0 = map(int,input().split(".")) A1,B1,C1 = map(int,input().split(".")) if A1 < A0: print("YES") elif A1 == A0: if B1 < B0: print("YES") elif B1 == B0: if C1 < C0: print("YES") else: print("NO") else: print("NO") else: print("NO")