#include <bits/stdc++.h>
using namespace std;
struct UF {
  vector<long long> par;
  vector<long long> sz;
  vector<long long> ed;
  UF() {}
  UF(long long n) {
    par.resize(n);
    sz.resize(n, 1);
    ed.resize(n, 0);
    for (long long i = 0; i < n; i++) par[i] = i;
  }
  long long find(long long x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);
  }
  void unite(long long x, long long y) {
    x = find(x);
    y = find(y);
    if (x == y) {
      ed[x]++;
      return;
    }
    if (sz[x] < sz[y]) swap(x, y);
    sz[x] += sz[y];
    ed[x] += ed[y] + 1;
    par[y] = x;
  }
  bool same(long long x, long long y) { return find(x) == find(y); }
};
signed main() {
  long long n, m;
  cin >> n >> m;
  UF uf(n);
  for (long long i = 0; i < m; i++) {
    long long a, b;
    cin >> a >> b;
    a--;
    b--;
    uf.unite(a, b);
  }
  bool ans = true;
  for (long long i = 0; i < n; i++) {
    if (uf.find(i) == i) {
      if (uf.sz[i] * (uf.sz[i] - 1) / 2 != uf.ed[i]) ans = false;
    }
  }
  cout << (ans ? "YES" : "NO") << endl;
}
