#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
using namespace std;
int parent[150000];
int size[150000];
long long int edges[150000];
struct dsu {
  void init(int n) {
    for (int i = 0; i < n; ++i) {
      parent[i] = i;
      size[i] = 1;
      edges[i] = 0;
    }
  }
  int p(int x) {
    if (parent[x] == x) return x;
    return parent[x] = p(parent[x]);
  }
  void unite(int x, int y) {
    int supx = p(x);
    int supy = p(y);
    if (supx != supy) {
      if (size[supx] > size[supy]) {
        parent[supy] = supx;
        size[supx] += size[supy];
        edges[supx] += edges[supy] + 1;
      } else {
        parent[supx] = supy;
        size[supy] += size[supx];
        edges[supy] += edges[supx] + 1;
      }
    } else {
      edges[supx]++;
    }
  }
};
int n, m, x, y;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  cin >> n >> m;
  dsu d;
  d.init(n);
  for (int i = 0; i < m; ++i) {
    cin >> x >> y;
    x--;
    y--;
    d.unite(x, y);
  }
  for (int i = 0; i < n; ++i) {
    if (parent[i] == i) {
      long long int ed = edges[i];
      long long int vertices = size[i];
      if (ed != (vertices * (vertices - 1)) / 2) {
        cout << "NO";
        return 0;
      }
    }
  }
  cout << "YES";
  return 0;
}
