P = list(map(int, input().split('.'))) L = list(map(int, input().split('.'))) if P[0] > L[0] or (P[0] == L[0] and P[1] > L[1]) or (P[0] == L[0] and P[1] == L[1] and P[2] >= L[2]): print('YES') else: print('NO')