#include <bits/stdc++.h>
using namespace std;
const int sz = 1e6;
int par[sz];
long long edges[sz];
int root(int i) {
  if (par[i] >= 0) return par[i] = root(par[i]);
  return i;
}
void merge(int x, int y) {
  x = root(x), y = root(y);
  if (x == y) return;
  if (par[y] < par[x]) swap(x, y);
  par[x] += par[y];
  par[y] = x;
  edges[x] += edges[y];
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) {
    par[i] = -1;
    edges[i] = 0;
  }
  for (int i = 0; i < m; ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    --a, --b;
    merge(a, b);
    ++edges[root(a)];
  }
  bool good = true;
  for (int i = 0; i < n; ++i)
    if (par[i] < 0) {
      long long csize = -par[i];
      if (csize * (csize - 1) != 2 * edges[i]) good = false;
    }
  if (good)
    printf("YES\n");
  else
    printf("NO\n");
}
