#include <bits/stdc++.h>
using namespace std;
int n, m, siz[200005], size[200005], x, y, fa[200005];
int getfa(int x) {
  if (fa[x] != x) fa[x] = getfa(fa[x]);
  return fa[x];
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) fa[i] = i, siz[i] = 1, size[i] = 0;
  for (int i = 1; i <= m; ++i) {
    scanf("%d%d", &x, &y);
    x = getfa(x);
    y = getfa(y);
    if (x == y) {
      size[x]++;
    } else {
      fa[x] = y;
      siz[y] += siz[x];
      size[y] += size[x] + 1;
    }
  }
  bool flag = true;
  for (int i = 1; i <= n; ++i) {
    x = getfa(i);
    if (size[x] != 1LL * siz[x] * (siz[x] - 1) / 2) flag = false;
  }
  if (flag)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
