#include <bits/stdc++.h>
using namespace std;
int pre[150050];
long long int cnt[150050];
int unionsearch(int root) {
  int son = root, tmp;
  while (pre[root] != root) {
    root = pre[root];
  }
  while (pre[son] != root) {
    tmp = pre[son];
    pre[son] = root;
    son = tmp;
  }
  return root;
}
void join(int root1, int root2) {
  root1 = unionsearch(root1);
  root2 = unionsearch(root2);
  if (root1 != root2) {
    pre[root1] = root2;
  }
}
int main() {
  int n, m, a, b;
  while (~scanf("%d%d", &n, &m)) {
    long long int sum = 0;
    memset(cnt, 0, sizeof(cnt));
    for (int i = 1; i <= n; i++) pre[i] = i;
    for (int i = 1; i <= m; i++) {
      scanf("%d%d", &a, &b);
      join(a, b);
    }
    for (int i = 1; i <= n; i++) {
      cnt[unionsearch(i)]++;
    }
    for (int i = 1; i <= n; i++) {
      if (cnt[i]) {
        sum += cnt[i] * (cnt[i] - 1) / 2;
      }
    }
    if (sum == m)
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}
