# coding: utf-8 def main(): N, M = map(int, input().split()) edges = [set() for _ in range(N)] for _ in range(M): a, b = map(int, input().split()) edges[a-1].add(b-1) edges[b-1].add(a-1) # 頂点0から距離2の点,経由点の候補 d2vs = [set() for _ in range(N)] for i in edges[0]: for j in edges[i]: d2vs[j].add(i) # (頂点0から距離2の点)から(頂点0から距離2の点)への辺があり、 # 別の頂点を経由して行けることを確認 for i in range(1, N): li = len(d2vs[i]) if li == 0: continue for j in edges[i]: if j == 0: continue lj = len(d2vs[j]) if lj == 0: continue if li == 1 and lj == 1: if d2vs[i].issubset(d2vs[j]) or \ tuple(d2vs[i])[0] == j: continue return True return False if main(): print("YES") else: print("NO")