#include <bits/stdc++.h>
using namespace std;
long long par[150010], ssize[150010], edges[150010];
long long root(long long a) {
  while (a != par[a]) {
    par[a] = par[par[a]];
    a = par[a];
  }
  return (a);
}
void makeUnion(long long a, long long b) {
  long long temp1 = root(a);
  long long temp2 = root(b);
  if (temp1 != temp2) {
    if (ssize[temp1] > ssize[temp2]) {
      par[temp2] = temp1;
      ssize[temp1] += ssize[temp2];
      edges[temp1] += edges[temp2] + 1;
    } else {
      par[temp1] = temp2;
      edges[temp2] += edges[temp1] + 1;
      ssize[temp2] += ssize[temp1];
    }
  } else {
    edges[temp1]++;
  }
}
signed main() {
  long long n, m;
  cin >> n >> m;
  for (long long i = 1; i <= n; i++) {
    par[i] = i;
    ssize[i] = 1;
  }
  while (m--) {
    long long a, b;
    cin >> a >> b;
    makeUnion(a, b);
  }
  for (long long i = 1; i <= n; i++) {
    if (par[i] == i) {
      if (ssize[i] > 2 && 2 * edges[i] != (ssize[i] * (ssize[i] - 1))) {
        cout << "NO" << endl;
        exit(0);
      }
    }
  }
  cout << "YES" << endl;
}
