#include <bits/stdc++.h>
using namespace std;
int z[150005];
long long tir[150005];
int find(int a) {
  if (a != z[a]) {
    z[a] = find(z[a]);
  }
  return z[a];
}
void mix(int a, int b) { z[find(a)] = find(b); }
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    z[i] = i;
    tir[i] = 0;
  }
  for (int j = 0; j < m; j++) {
    int a, b;
    scanf("%d%d", &a, &b);
    mix(a, b);
  }
  for (int i = 1; i <= n; i++) {
    tir[find(i)]++;
  }
  long long sum = 0;
  for (int i = 1; i <= n; i++) {
    sum += ((tir[i] * (tir[i] - 1)) / 2);
  }
  if (sum == m)
    puts("YES");
  else
    puts("NO");
  return 0;
}
