#include <bits/stdc++.h>
using namespace std;
const long long N = 200002;
long long n, m, l, r, p, t, k, ans, sum, tot, cnt, a[N], b[N], c[N], f[N];
map<long long, long long> mp;
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while ('0' <= ch && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
long long find(long long x) {
  if (x == f[x]) return x;
  return f[x] = find(f[x]);
}
signed main() {
  n = read();
  m = read();
  for (long long i = 1; i <= n; i++) f[i] = i, b[i] = 1;
  for (long long i = 1; i <= m; i++) {
    long long x = read(), y = read();
    long long fx = find(x), fy = find(y);
    if (fx == fy) continue;
    f[fx] = fy;
    b[fy] += b[fx];
    b[fx] = 0;
  }
  for (long long i = 1; i <= n; i++) {
    if (b[i] > 1) sum += b[i] * (b[i] - 1) / 2;
  }
  if (sum == m)
    puts("YES");
  else
    puts("NO");
  return 0;
}
