a = input().split(".") b = input().split(".") def judge(a, b): if a[0] > b[0]: return 'YES' else: return 'NO' if a[0] >= b[0] and a[1] > b[1]: return 'YES' else: return 'NO' if a[0] >= b[0] and a[1] >= b[1] and a[2] >= b[2]: return 'YES' else: return 'NO' print(judge(a,b))