#include<iostream>
#define N 1005
using namespace std;
int father[N];
int findFather(int x){
if(x == father[x]) return x;
else{
int tp = findFather(father[x]);
father[x] = tp;
return tp;
}
}
int main(){
int n,m;
while(cin>>n>>m){
int x,y;
for(int i = 1;i <= n;i++){
father[i] = i;
}
for(int i = 0;i < m; i++){
cin>>x>>y;
int faX = findFather(x);
int faY = findFather(y);
if(faX != faY){
father[x] = y;
}
}
int ans = 0;
for(int j = 1;j <= n; j++){
if(father[j] == j)
ans++;
}
if(ans == 1) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
return 0;
}