#include <bits/stdc++.h>
using namespace std;
int n, m;
int a, b;
vector<vector<int> > g;
vector<int> used;
pair<long long, long long> dfs(int v) {
  used[v] = true;
  pair<long long, long long> res = {1, 0};
  for (auto to : g[v]) {
    if (!used[to]) {
      pair<long long, long long> res2 = dfs(to);
      res.first += res2.first;
      res.second += res2.second;
    }
    res.second += 1;
  }
  return res;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  g.resize(n);
  used.assign(n, false);
  for (int i = 0; i < m; ++i) {
    cin >> a >> b;
    g[a - 1].push_back(b - 1);
    g[b - 1].push_back(a - 1);
  }
  for (int i = 0; i < n; ++i) {
    if (!used[i]) {
      pair<long long, long long> res = dfs(i);
      if (res.first * (res.first - 1) != res.second) {
        cout << "NO" << endl;
        return 0;
      }
    }
  }
  cout << "YES" << endl;
  return 0;
}
