#include <bits/stdc++.h>
using namespace std;
int a, b;
long long int POW(long long int p, int b) {
  long long int ans = 1LL;
  while (b > 0) {
    if (b & 1) {
      ans = ans * 1LL * p;
    }
    b /= 2;
    p = p * 1LL * p;
  }
  return ans;
}
const int N = 1e6 + 2;
vector<int> g[N];
long long int sz;
long long int kitnaedge;
int n, m;
bool visi[N];
void dfs(int u) {
  if (visi[u]) return;
  visi[u] = true;
  sz++;
  kitnaedge += g[u].size();
  for (int i = 0; i < g[u].size(); i++) {
    dfs(g[u][i]);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int x, y;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  for (int i = 1; i <= n; i++) {
    if (!visi[i]) {
      sz = 0;
      kitnaedge = 0;
      dfs(i);
      kitnaedge /= 2;
      if (sz * 1LL * (sz - 1) / 2 != kitnaedge) cout << "NO", exit(0);
    }
  }
  cout << "YES";
}
