a,b,c = map(int,input().split(".")) d,e,f = map(int,input().split(".")) if a > d: print("YES") elif a == d: if b > e: print("YES") elif b == e: if c >= f: print("YES") else: print("NO") else: print("NO") else: print("NO")