#include <bits/stdc++.h>
using namespace std;
const int64_t N = 2e5 + 338;
vector<int64_t> g[N];
vector<int64_t> l;
bool used[N];
int64_t n, m;
void dfs(int64_t v) {
  used[v] = true;
  l.push_back(v);
  for (int64_t i : g[v])
    if (!used[i]) dfs(i);
}
bool check() {
  ;
  for (int64_t i : l)
    ;
  ;
  int64_t v = l.size();
  int64_t e = 0;
  for (int64_t i : l) e += g[i].size();
  ;
  ;
  return e == v * (v - 1);
}
bool is_good() {
  for (int64_t i = 0; i < N; i++) used[i] = false;
  for (int64_t i = 0; i < n; i++) {
    if (!used[i]) {
      l.clear();
      dfs(i);
      if (!check()) return false;
    }
  }
  return true;
}
signed work();
signed main() {
  ;
  ;
  ;
  return work();
}
signed work() {
  cin >> n >> m;
  for (int64_t i = 0; i < m; i++) {
    int64_t u, v;
    cin >> u >> v;
    u--, v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  if (is_good())
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
