#include <bits/stdc++.h>
using namespace std;
class Dsu {
 public:
  vector<int> p;
  int n;
  Dsu(int _n) : n(_n) {
    p.resize(n);
    iota(p.begin(), p.end(), 0);
  }
  inline int get(int x) { return (x == p[x] ? x : (p[x] = get(p[x]))); }
  inline bool unite(int x, int y) {
    x = get(x);
    y = get(y);
    if (x != y) {
      p[x] = y;
      return true;
    }
    return false;
  }
};
int main() {
  ios_base::sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  Dsu d(n);
  for (int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    d.unite(u, v);
  }
  vector<int> comps(n);
  for (int i = 0; i < n; ++i) {
    comps[d.get(i)]++;
  }
  long long correct = 0;
  for (int i = 0; i < n; ++i) {
    correct += 1ll * comps[i] * (comps[i] - 1) / 2;
  }
  cout << (correct == m ? "YES" : "NO") << '\n';
  return 0;
}
