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