#include <bits/stdc++.h>
using namespace std;
const int N = 150001;
int par[N];
long long int sizep[N];
int n, m;
int c2 = 0;
int c1 = 0;
void make_set(int i) {
  par[i] = i;
  sizep[i] = 1;
}
int findp(int i) {
  if (par[i] == i) {
    return i;
  }
  return par[i] = findp(par[i]);
}
void merge(int i, int j) {
  int pi = findp(i);
  int pj = findp(j);
  if (pi != pj) {
    if (sizep[pi] < sizep[pj]) {
      swap(pi, pj);
    }
    par[pj] = par[pi];
    sizep[pi] += sizep[pj];
  }
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    make_set(i);
  }
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    merge(x, y);
  }
  long long int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (par[i] == i) {
      ans += (sizep[i] * (sizep[i] - 1)) / 2;
    }
  }
  if (ans == m) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}
