#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
    #define debug(...) printf(__VA_ARGS__)
#else
    #define debug(...) (void)0
#endif
#define mp make_pair
#define pb push_back
#define LL long long
#define pii pair<int,int>
#define PII pair<long long, long long>
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
const int inf = 0x7fffffff; //beware overflow
const LL INF = 0x7fffffffffffffff; //beware overflow
#define mem(x, y) memset(x, (y), sizeof(x) );
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
template<typename A, typename B>
ostream& operator <<(ostream &s, const pair<A,B> &p) {
     return s<<"("<<p.first<<","<<p.second<<")";
}
template<typename T>
ostream& operator <<(ostream &s, const vector<T> &c) {
    s << "[ ";
    for (auto it : c) s << it << " ";
    s << "]";
    return s;
}
template<typename T>
ostream& operator << (ostream &o, const set<T> &st) {
    o << "{";
    for (auto it=st.begin(); it!=st.end(); it++) o << (it==st.begin() ? "" : ", ") << *it;
    return o << "}";
}
template<typename T1, typename T2>
ostream& operator << (ostream &o, const map<T1, T2> &mp) {
    o << "{";
    for (auto it=mp.begin(); it!=mp.end(); it++) {
        o << (it==mp.begin()?"":", ") << it->fi << ":" << it->se;
    }
    o << "}";
    return o;
}
#define maxn 100005
int n, m;
vector<int> G[maxn];
bool co[maxn];
int degree[maxn];
struct edge{ int from, to; }e[maxn];
int E;
struct X{
    int deg, ind;
    bool operator< (const X& rhs) const {
        if( deg != rhs.deg) return deg < rhs.deg;
        return ind < rhs.ind;
    };

};
int main() {
    cin>>n>>m;
    mem(co, false);
    if(m == n-1) {
        E = 0;
        for(int i =0;i<m;i++) {
            int a, b; scanf("%d %d", &a, &b);
            a--, b--;
            G[a].pb(b), G[b].pb(a);
        }
//        for(int i = 0; i < n; i++) degree[i] = SZ(G[i]);
        set<X> s;
        for(int i = 0; i < n;i++) s.insert( X{ SZ(G[i]), i} );
        while(s.size()>2) {
//            cout<<s.size()<<endl;
            auto tp = *s.begin();
            debug("%d %d\n", tp.deg, tp.ind);
            assert( tp.deg == 1);
            s.erase(s.begin());
            set<X>::iterator it;
            auto nxt = *(it=s.lower_bound( X{ G[ G[tp.ind][0] ].size(), G[tp.ind][0] } ));
            assert( nxt.ind == G[tp.ind][0] );
            s.erase(it);
            G[nxt.ind].erase( find(all(G[nxt.ind]),tp.ind) );
            (nxt.deg) --;
            s.insert( nxt );

            if( !co[tp.ind] ) co[nxt.ind] ^= 1;
        }
//      debug("%d %d\n",s.begin()->ind, prev(s.end())->ind);
        puts( (co[s.begin()->ind] ^ co[s.rbegin()->ind])? "NO":"YES");
    }else puts("-1");

}
