#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");
    }
 
}