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