using System;
using System.Linq;
using System.Linq.Expressions;
using System.Collections.Generic;
using Debug = System.Diagnostics.Debug;
using StringBuilder = System.Text.StringBuilder;
//using System.Numerics;
using Number = System.Int64;
namespace Program
{
public class Solver
{
///
/// meet in middle
///
public void Solve()
{
var n = sc.Integer();
var m = sc.Integer();
var G = Enumerate(n, x => new List());
for (int i = 0; i < m; i++)
{
var f = sc.Integer() - 1;
var t = sc.Integer() - 1;
G[f].Add(t);
G[t].Add(f);
}
var dp = Enumerate(n, x => new HashSet());
dp[0].Add(-1);
for (int i = 0; i < 2; i++)
{
var next = Enumerate(n, x => new HashSet());
for (int j = 0; j < n; j++)
{
if (dp[j].Count == 0) continue;
foreach (var to in G[j])
{
if (to == 0) continue;
if (dp[j].Contains(to) && dp[j].Count == 1) continue;
next[to].Add(j);
}
}
dp = next;
}
for (int i = 1; i < n; i++)
{
foreach (var to in G[i])
{
if (dp[i].Contains(to) && dp[i].Count == 1) continue;
if (dp[to].Contains(i) && dp[to].Count == 1) continue;
if (dp[i].Count != dp[to].Count)
{
IO.Printer.Out.WriteLine("YES");
return;
}
else
{
foreach(var x in dp[i])
{
if (dp[to].Contains(x)) continue;
IO.Printer.Out.WriteLine("YES");
return;
}
}
}
}
IO.Printer.Out.WriteLine("NO");
}
public IO.StreamScanner sc = new IO.StreamScanner(Console.OpenStandardInput());
static T[] Enumerate(int n, Func f) { var a = new T[n]; for (int i = 0; i < n; ++i) a[i] = f(i); return a; }
static public void Swap(ref T a, ref T b) { var tmp = a; a = b; b = tmp; }
}
}
#region main
static class Ex
{
static public string AsString(this IEnumerable ie) { return new string(System.Linq.Enumerable.ToArray(ie)); }
static public string AsJoinedString(this IEnumerable ie, string st = " ") { return string.Join(st, ie); }
static public void Main()
{
var solver = new Program.Solver();
solver.Solve();
Program.IO.Printer.Out.Flush();
}
}
#endregion
#region Ex
namespace Program.IO
{
using System.IO;
using System.Text;
using System.Globalization;
public class Printer: StreamWriter
{
static Printer() { Out = new Printer(Console.OpenStandardOutput()) { AutoFlush = false }; }
public static Printer Out { get; set; }
public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
public Printer(System.IO.Stream stream) : base(stream, new UTF8Encoding(false, true)) { }
public Printer(System.IO.Stream stream, Encoding encoding) : base(stream, encoding) { }
public void Write(string format, T[] source) { base.Write(format, source.OfType