#include <bits/stdc++.h>
using namespace std;
long long a, b, c, d, e, i, j, k, l, m, n, q, r, u, v, w, x, y, z, mn, mx, dx,
    dy;
void dfs(long long v, vector<bool> &vis, vector<long long> adj[],
         long long &cnt) {
  vis[v] = true;
  cnt++;
  for (auto u : adj[v])
    if (!vis[u]) dfs(u, vis, adj, cnt);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long t = 1;
  while (t--) {
    cin >> n >> m;
    vector<long long> adj[n + 1];
    for (long long i = 0; i < m; i++) {
      cin >> a >> b;
      adj[a].push_back(b);
      adj[b].push_back(a);
    }
    long long edges = 0;
    vector<bool> vis(n + 1, false);
    for (long long i = 0; i < n; i++) {
      if (!vis[i]) {
        long long cnt = 0;
        dfs(i, vis, adj, cnt);
        edges += (cnt * (cnt - 1)) / 2;
      }
    }
    if (edges == m)
      cout << "YES";
    else
      cout << "NO";
  h:;
    cout << "\n";
  }
  return 0;
}
