#include <bits/stdc++.h>
using namespace std;
vector<vector<long long> > g;
vector<bool> used;
void dfs(long long v, long long &h, long long &e) {
  used[v] = true;
  h++;
  e += g[v].size();
  for (int i = 0; i < g[v].size(); ++i) {
    if (!used[g[v][i]]) dfs(g[v][i], h, e);
  }
}
int main() {
  long long n, m;
  cin >> n >> m;
  g.resize(n);
  used.resize(n);
  for (int i = 0; i < m; ++i) {
    long long u, v;
    cin >> u >> v;
    g[u - 1].push_back(v - 1);
    g[v - 1].push_back(u - 1);
  }
  for (int i = 0; i < n; ++i) {
    if (!used[i]) {
      long long h = 0, e = 0;
      dfs(i, h, e);
      if (h * (h - 1) != e) {
        cout << "NO";
        return 0;
      }
    }
  }
  cout << "YES";
  return 0;
}
