#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll dfs(ll node, vector<vector<ll>>& adj, vector<bool>& vu) {
  ll ret = 1;
  vu[node] = true;
  for (int i : adj[node]) {
    if (!vu[i]) ret += dfs(i, adj, vu);
  }
  return ret;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n, m, a, b;
  cin >> n >> m;
  vector<vector<ll>> adj(n + 1);
  for (ll i = 0; i < m; ++i) {
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  vector<bool> vu(n + 1);
  ll tot = 0;
  for (ll i = 1; i <= n; ++i) {
    if (!vu[i]) {
      ll nb = dfs(i, adj, vu);
      tot += nb * (nb - 1) / 2;
      if (tot > m) {
        cout << "NO";
        return 0;
      }
    }
  }
  if (tot == m)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
