#include <bits/stdc++.h>
using namespace std;
int n = 0;
int m = 0;
int a = 0;
int b = 0;
long long component = 0;
long long degree = 0;
vector<vector<int>> g;
vector<bool> w;
void dfs(int);
int main() {
  cin >> n >> m;
  g.resize(n);
  w.resize(n, false);
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  for (int i = 0; i < n; i++) {
    if (!w[i]) {
      degree = 0;
      component = 0;
      dfs(i);
      if (degree != component * (component - 1)) {
        cout << "NO" << endl;
        return 0;
      }
    }
  }
  cout << "YES" << endl;
  return 0;
}
void dfs(int v) {
  w[v] = true;
  component++;
  degree += g[v].size();
  int t = 0;
  for (int i = 0; i < g[v].size(); i++) {
    t = g[v][i];
    if (!w[t]) dfs(t);
  }
  return;
}
