#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> G[150005];
int F[150005];
void DFS(int v, int color) {
  F[v] = color;
  for (int j = 0; j < (int)G[v].size(); ++j) {
    if (F[G[v][j]] == 0) {
      DFS(G[v][j], color);
    }
  }
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    F[i] = 0;
  }
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  int color = 0;
  for (int i = 0; i < n; ++i) {
    if (F[i] == 0) {
      ++color;
      DFS(i, color);
    }
  }
  long long int Colors[color];
  for (int i = 0; i < color; ++i) {
    Colors[i] = 0L;
  }
  for (int i = 0; i < n; ++i) {
    ++Colors[F[i] - 1];
  }
  long long int ans = 0;
  for (int i = 0; i < color; ++i) {
    ans += (Colors[i] * (Colors[i] - 1)) / 2;
  }
  if (ans == (long long int)m) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}
