#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
int n, m;
const int N = 2e5 + 5;
vector<int> adj[N];
bool vis[N];
vector<int> c;
void dfs(int src) {
  vis[src] = true;
  c.push_back(src);
  for (auto neig : adj[src]) {
    if (!vis[neig]) dfs(neig);
  }
}
bool check() {
  long long v = c.size();
  long long cnt = 0;
  for (auto i : c) {
    cnt += adj[i].size();
  }
  cnt /= 2;
  if (cnt == v * (v - 1) / 2) return true;
  return false;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  bool ans = true;
  for (int i = 0; i < n; i++) {
    if (!vis[i]) {
      dfs(i);
    }
    ans &= check();
    c.clear();
  }
  if (ans)
    cout << "YES\n";
  else
    cout << "NO\n";
  return 0;
}
