#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define int long long
#define mp make_pair
#define pb push_back

#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

constexpr int INF = (int)1e18;
constexpr int N = (int)2e5 + 111;
constexpr int md = (int)998244353;

vector<int> g[N];
vector<int> additional[N];

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

struct DSU{
    vector<int> parent;
    DSU(){}
    DSU(int n){
        parent.resize(n+1);
        for(int i = 0; i <= n; i++)
            parent[i] = i;
    }
    int get(int x){
        return parent[x] == x ? x : parent[x] = get(parent[x]);
    }
    void union_sets(int a,int b){
        a = get(a), b = get(b);
        if(a == b)
            return;
        if(rnd()&1)
            swap(a,b);
        parent[a] = b;
    }
    bool connected(int a,int b){
        return get(a) == get(b);
    }
};

void solve(){
    int n,m;
    cin >> n >> m;

    vector<pair<int,int>> edges;
    for(int i = 0; i < m; i++){
        int a,b;
        cin >> a >> b;
        if(a > b)
            swap(a,b);
        edges.pb(mp(a,b));
    }

    sort(edges.begin(),edges.end());

    DSU d(n+1);

    for(auto&[a,b] : edges){
        if(!d.connected(a,b)){
            g[a].pb(b);
            g[b].pb(a);
        } else {
            additional[a].pb(b);
            additional[b].pb(a);
        }
    }

    for(int i = 1; i <= n; i++){
        if(g[i].size() == 1 && additional[i].empty()){
            cout << "NO\n";
            return;
        }
    }
    assert(false);

    return;
}

signed main(){
    ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    int tests = 1;
//    cin >> tests;
    for(int test = 1; test <= tests; test++){
        solve();
    }
    return 0;
}
/**
make VUDOI great again.

**/
