#include<bits/stdc++.h>
#include<stdlib.h>
#define pb push_back
#define ff first
#define ss second
#define int long long
#define let long long
//#define mp make_pair
#define cin_arr(arr,n) for (int i=0; i<n;i++) cin>>arr[i];
#define cout_arr(arr,n) for (int i=0; i<n;i++) cout<<arr[i]<<" ";
#define cout_set(st) for (auto i:st) cout<<i<<" ";
#define endl '\n'
using namespace std;
int n,m;
vector<int>v[100005];
int color[100005];

void dfs(int x){
    if (color[x]==2) return;
    color[x]++;
    for (int i=0; i<v[x].size();i++) {
        dfs(v[x][i]);
    }
}

int32_t main()
{
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);

    cin>>n>>m;
    for (int i=0; i<m;i++) {
        int x,y;
        cin>>x>>y;
        x--;y--;
        v[x].pb(y);
        v[y].pb(x);
    }
    dfs(0);
    for (int i=0; i<n;i++) {
        if (color[i]!=2) {
            cout<<"NO";
            return;
        }
    }
    cout<<"1";
}

