#include <bits/stdc++.h>
using namespace std;
const int N=100100;
int v, u, n, m, flag = 1, vis[N];
vector<int> g[N];

void dfs(int v)
{
    vis[v] = 1;
    for (int i=0; i<g[v].size(); i++)
    {
        int u= g[v][i];
        if (vis[u] == 0)
            dfs(u);
    }
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

	int n, m;
    cin >> n >> m;
    for (int i=1; i<=m; i++)
    {
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    for (int i=1; i<=n; i++) if (g[i].size() < 2) 
    {
        cout<<"NO"<<"\n";
        return 0;
    }
    dfs(1);
    for (int i=1; i<=n; i++)
    {
        if (vis[i] == 0) 
        {
            cout<<"NO"<<"\n";
            return 0;
        }
    }
    
}
