#include <bits/stdc++.h>
using namespace std;
long long n, m;
vector<long long> edg[200005];
bool vis[200005];
long long col[200005];
map<long long, long long> cou;
long long curr = 1;
void dfs(long long i) {
  vis[i] = true;
  for (long long j = 0; j < edg[i].size(); j++) {
    if (!vis[edg[i][j]]) {
      col[edg[i][j]] = curr;
      cou[curr] += 1;
      dfs(edg[i][j]);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  ;
  long long precision = numeric_limits<double>::digits10;
  ;
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    long long u, v;
    cin >> u >> v;
    edg[u].push_back(v);
    edg[v].push_back(u);
  }
  for (long long i = 1; i <= n; i++) {
    if (!vis[i]) {
      cou[curr] += 1;
      col[i] = curr;
      dfs(i);
      curr++;
    }
  }
  vector<long long> cnt(curr, 0);
  bool pos = true;
  for (long long i = 1; i <= n; i++) {
    for (long long j = 0; j < edg[i].size(); j++) {
      long long u = i, v = edg[i][j];
      cnt[col[u]] += 1;
    }
  }
  for (long long i = 1; i <= curr - 1; i++) {
    if (cnt[i] != cou[i] * (cou[i] - 1)) {
      pos = false;
      break;
    }
  }
  if (pos)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
