#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > graph(200000);
vector<bool> vis(200000, false);
int v = 0, e = 0;
void dfs(int p) {
  vis[p] = true;
  ++v;
  e += graph[p].size();
  for (int c : graph[p]) {
    if (!vis[c]) {
      dfs(c);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m;
  cin >> n >> m;
  int a, b;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  int ok = 0;
  for (int i = 1; i <= n; i++) {
    v = 0;
    e = 0;
    if (!vis[i]) {
      dfs(i);
      if (e != (long long int)v * (v - 1)) {
        cout << "NO"
             << "\n";
        return 0;
      }
    }
  }
  cout << "YES"
       << "\n";
  return 0;
}
