#include <bits/stdc++.h>
const int M = 1e9 + 7;
using namespace std;
vector<long long> adj[150001];
vector<bool> vis(150001, false);
long long ans = 0, edg = 0, no = 0, cmp = 0;
void dfs(int node) {
  vis[node] = 1;
  no++;
  edg += adj[node].size();
  for (auto child : adj[node]) {
    if (!vis[child]) {
      dfs(child);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t = 1;
  while (t--) {
    long long n, m, a, b;
    cin >> n >> m;
    for (long long i = 1; i <= m; i++) {
      cin >> a >> b;
      adj[a].push_back(b);
      adj[b].push_back(a);
    }
    for (long long i = 1; i <= n; i++) {
      if (adj[i].size() == 0 || vis[i]) continue;
      edg = 0;
      no = 0;
      dfs(i);
      cmp++;
      if (edg == ((no) * (no - 1))) ans++;
    }
    cout << ((ans == cmp) ? "YES" : "NO");
  }
  return 0;
}
