from itertools import permutations D = list(map(int, input().split())) for l in permutations(D): for i in range(5): sub_l = [l[i], l[i+1], l[i+2]] if l[i+1] in [min(sub_l), max(sub_l)] and l[i] < l[i+2] and 3 == len(set(sub_l)): continue else: break else: print('YES') break else: print('NO')