n,m = map(int,input().split()) g = [set() for _ in range(n)] for i in range(m): a,b = map(int,input().split()) g[a-1].add(b-1) g[b-1].add(a-1) size = [0]*n res = [None]*n for i in range(1,n): s = g[0]&g[i] if len(s) >= 3: size[i] = 3 else: size[i] = len(s) res[i] = s for a in range(1,n): if size[a] == 0: continue for b in g[a]: if b==0 or size[b] == 0: continue if size[a] >= 3 or size[b] >= 3: print("YES") exit() for c in res[a]: for d in res[b]: if c != d and b != c and a != d: print("YES") exit() print("NO")