#include <bits/stdc++.h>
using namespace std;
long long parent[150000LL + 5], number[150000LL + 5];
long long par(long long x) {
  if (parent[x] != x) parent[x] = par(parent[x]);
  return parent[x];
}
void uni(long long a, long long b) {
  if (a == b) return;
  parent[a] = b;
  number[b] += number[a];
}
int main() {
  long long n, m, i, u, v;
  cin >> n >> m;
  for (i = 1; i <= n; i++) parent[i] = i, number[i] = 1;
  for (i = 0; i < m; i++) {
    cin >> u >> v;
    uni(par(u), par(v));
  }
  long long val = 0;
  for (i = 1; i <= n; i++) {
    if (par(i) == i) val += ((number[i] * (number[i] - 1)) / 2);
  }
  if (val == m)
    cout << "YES\n";
  else
    cout << "NO\n";
  return 0;
}
