#include <bits/stdc++.h>
using namespace std;
int n, m, a, b;
const int MAX_N = 150005;
int fa[MAX_N];
int du[MAX_N];
int ran[MAX_N];
int found(int x) { return x == fa[x] ? x : fa[x] = found(fa[x]); }
void bing(int x, int y) {
  x = found(x);
  y = found(y);
  if (x != y) {
    fa[x] = y;
  }
}
int main() {
  cin >> n >> m;
  for (int i = 0; i <= n; i++) {
    fa[i] = i;
    du[i] = 0;
    ran[i] = 0;
  }
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    bing(a, b);
    du[a]++;
    du[b]++;
  }
  for (int i = 0; i <= n; i++) {
    int x = found(i);
    ran[x]++;
  }
  int flag = 0;
  for (int i = 0; i <= n; i++) {
    int x = found(i);
    if (du[i] != ran[x] - 1) {
      flag = 1;
      break;
    }
  }
  if (!flag) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}
