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