#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
vector<int> adj[200010];
bool vis[200010];
void dfs(int i, long long &cnt) {
  vis[i] = true;
  ++cnt;
  for (int x : adj[i])
    if (!vis[x]) dfs(x, cnt);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, m;
  cin >> n >> m;
  for (long long i = 0; i < (m); ++i) {
    int v1, v2;
    cin >> v1 >> v2;
    adj[v1].push_back(v2);
    adj[v2].push_back(v1);
  }
  long long edges = 0LL;
  for (long long i = (1); i < (n + 1); ++i)
    if (!vis[i]) {
      long long cnt = 0;
      dfs(i, cnt);
      edges += (cnt * (cnt - 1) / 2LL);
    }
  if (edges == m)
    cout << "YES";
  else
    cout << "NO";
  cout << '\n';
  return 0;
}
