#include <bits/stdc++.h>
using namespace std;
struct pair_hash {
  template <class T1, class T2>
  std::size_t operator()(const std::pair<T1, T2>& p) const {
    auto h1 = std::hash<T1>{}(p.first);
    auto h2 = std::hash<T2>{}(p.second);
    return h1 ^ h2;
  }
};
using vote = pair<long long int, long long int>;
using Unordered_map = unordered_map<vote, long long int, pair_hash>;
bool comp(pair<long long int, long long int> a,
          pair<long long int, long long int> b) {
  if (a.second == b.second) return a.first < b.first;
  return a.second < b.second;
}
void dfs(vector<vector<long long int>>& h, vector<long long int>& v,
         long long int n, long long int& e, long long int& c) {
  if (v[n] == 1) return;
  v[n] = 1;
  c++;
  e += h[n].size();
  for (long long int i = 0; i < h[n].size(); i++) {
    long long int j = h[n][i];
    if (!v[j]) {
      dfs(h, v, j, e, c);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  {
    long long int n, m;
    cin >> n >> m;
    long long int f = 1;
    vector<vector<long long int>> h(n + 1);
    for (long long int i = 0; i < m; i++) {
      long long int x, y;
      cin >> x >> y;
      h[x].push_back(y);
      h[y].push_back(x);
    }
    vector<long long int> v(n + 1);
    for (long long int i = 1; i <= n; i++) {
      if (!v[i]) {
        long long int e = 0, c = 0;
        dfs(h, v, i, e, c);
        if (e == ((c - 1) * c)) {
        } else
          f = 0;
      }
    }
    if (f == 1)
      cout << "YES";
    else
      cout << "NO";
    cout << endl;
  }
}
