#include<bits/stdc++.h>
using namespace std;
const int N = 5010;
int n, m;
int p[N];
int find(int x)
{
if(x != p[x]) return p[x] = find(p[x]);
return p[x];
}
int main()
{
cin >> n >> m;
for(int i = 1; i <= n; i ++) p[i] = i;
int cnt = n;
for(int i = 0; i < m; i ++)
{
int a, b;
cin >> a >> b;
a = find(a), b = find(b);
if(a != b)
{
cnt --;
p[a] = b;
}
}
if(cnt == 1 && n == m) puts("YES");
else puts("NO");
return 0;
}