#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int n,m;
int const N = 200005;
vector<int> v[N];
vector<bool> visited(N,false);
bool cycle = false;
void bfs(int i){
if(cycle)return;
queue<pair<int,int>> q; // pair of <node,parent>
q.push({i,-1});
while(q.size()){
pair<int,int> it = q.front();q.pop();
int node = it.first, parent = it.second;
visited[node] = true;
for(int w: v[node]){
if(w==parent)continue;
if(visited[w]){
cycle = true;return;
}
q.push({w,node});
}
}
}
int main()
{
cin >> n >> m;
while(m--){
int a,b;
cin >> a >> b;
v[a].push_back(b);
v[b].push_back(a);
}
for(int i = 1;i<=n;i++){
if(cycle)break;
if(!visited[i]){
bfs(i);
}
}
if(!cycle){
puts("NO");
}
else{
puts("YES");
}
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KI2luY2x1ZGU8aW9zdHJlYW0+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG4sbTsKCmludCBjb25zdCBOID0gMjAwMDA1OwoKdmVjdG9yPGludD4gdltOXTsKCnZlY3Rvcjxib29sPiB2aXNpdGVkKE4sZmFsc2UpOwoKYm9vbCBjeWNsZSA9IGZhbHNlOwoKdm9pZCBiZnMoaW50IGkpewogICAgaWYoY3ljbGUpcmV0dXJuOwoKICAgIHF1ZXVlPHBhaXI8aW50LGludD4+IHE7IC8vIHBhaXIgb2YgPG5vZGUscGFyZW50PgoKICAgIHEucHVzaCh7aSwtMX0pOwoKICAgIHdoaWxlKHEuc2l6ZSgpKXsKICAgICAgICBwYWlyPGludCxpbnQ+IGl0ID0gcS5mcm9udCgpO3EucG9wKCk7CgogICAgICAgIGludCBub2RlID0gaXQuZmlyc3QsIHBhcmVudCA9IGl0LnNlY29uZDsKCiAgICAgICAgdmlzaXRlZFtub2RlXSA9IHRydWU7CgogICAgICAgIGZvcihpbnQgdzogdltub2RlXSl7CiAgICAgICAgICAgIGlmKHc9PXBhcmVudCljb250aW51ZTsKICAgICAgICAgICAgaWYodmlzaXRlZFt3XSl7CiAgICAgICAgICAgICAgICBjeWNsZSA9IHRydWU7cmV0dXJuOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHEucHVzaCh7dyxub2RlfSk7CiAgICAgICAgfQogICAgfQp9CgogCmludCBtYWluKCkKewogCiAgICBjaW4gPj4gbiA+PiBtOwoKICAgIHdoaWxlKG0tLSl7CiAgICAgICAgaW50IGEsYjsKCiAgICAgICAgY2luID4+IGEgPj4gYjsKCiAgICAgICAgdlthXS5wdXNoX2JhY2soYik7CiAgICAgICAgdltiXS5wdXNoX2JhY2soYSk7CiAgICB9CgogICAgZm9yKGludCBpID0gMTtpPD1uO2krKyl7CiAgICAgICAgaWYoY3ljbGUpYnJlYWs7CiAgICAgICAgaWYoIXZpc2l0ZWRbaV0pewogICAgICAgICAgICBiZnMoaSk7CiAgICAgICAgfQogICAgfQoKICAgIGlmKCFjeWNsZSl7CiAgICAgICAgcHV0cygiTk8iKTsKICAgIH0KCiAgICBlbHNlewogICAgICAgIHB1dHMoIllFUyIpOwogICAgfQogCn0=