#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 dfs(int i, int parent){
if(cycle)return;
visited[i] = true;
for(int node: v[i]){
if(node==parent)continue;
if(visited[node]){
cycle = true;
return;
}
dfs(node,i);
}
}
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]){
dfs(i,-1);
}
}
if(!cycle){
puts("NO");
}
else{
puts("YES");
}
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KI2luY2x1ZGU8aW9zdHJlYW0+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG4sbTsKCmludCBjb25zdCBOID0gMjAwMDA1OwoKdmVjdG9yPGludD4gdltOXTsKCnZlY3Rvcjxib29sPiB2aXNpdGVkKE4sZmFsc2UpOwoKYm9vbCBjeWNsZSA9IGZhbHNlOwoKdm9pZCBkZnMoaW50IGksIGludCBwYXJlbnQpewogICAgaWYoY3ljbGUpcmV0dXJuOwogICAgdmlzaXRlZFtpXSA9IHRydWU7CiAKICAgIGZvcihpbnQgbm9kZTogdltpXSl7CiAgICAgICAgaWYobm9kZT09cGFyZW50KWNvbnRpbnVlOwogICAgICAgIGlmKHZpc2l0ZWRbbm9kZV0pewogICAgICAgICAgICBjeWNsZSA9IHRydWU7CiAgICAgICAgICAgIHJldHVybjsKICAgICAgICB9CiAgICAgICAgZGZzKG5vZGUsaSk7CiAgICB9Cn0KCiAKaW50IG1haW4oKQp7CiAKICAgIGNpbiA+PiBuID4+IG07CgogICAgd2hpbGUobS0tKXsKICAgICAgICBpbnQgYSxiOwoKICAgICAgICBjaW4gPj4gYSA+PiBiOwoKICAgICAgICB2W2FdLnB1c2hfYmFjayhiKTsKICAgICAgICB2W2JdLnB1c2hfYmFjayhhKTsKICAgIH0KCiAgICBmb3IoaW50IGkgPSAxO2k8PW47aSsrKXsKICAgICAgICBpZihjeWNsZSlicmVhazsKICAgICAgICBpZighdmlzaXRlZFtpXSl7CiAgICAgICAgICAgIGRmcyhpLC0xKTsKICAgICAgICB9CiAgICB9CgogICAgaWYoIWN5Y2xlKXsKICAgICAgICBwdXRzKCJOTyIpOwogICAgfQoKICAgIGVsc2V7CiAgICAgICAgcHV0cygiWUVTIik7CiAgICB9CiAKfQ==