#include <bits/stdc++.h>
using namespace std;
long long findPar(vector<long long> &par, long long x) {
  return par[x] == x ? x : par[x] = findPar(par, par[x]);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, m, a, b;
  cin >> n >> m;
  vector<long long> par(n), size(n, 1), ed(n, 0);
  for (long long i = 0; i < n; i++) par[i] = i;
  for (long long i = 0; i < m; i++) {
    cin >> a >> b;
    a--;
    b--;
    a = findPar(par, a);
    b = findPar(par, b);
    if (a != b)
      par[a] = b, ed[b] += ed[a] + 1, size[b] += size[a];
    else
      ed[a]++;
  }
  bool p = 1;
  for (long long i = 0; i < n; i++)
    if (par[i] == i) {
      if (ed[i] != (size[i] * (size[i] - 1) / 2)) {
        p = 0;
        break;
      }
    }
  cout << (p ? "YES" : "NO");
}
