#include <bits/stdc++.h>
using namespace std;
const int N = 1001000;
vector<int> g[N];
bool seen[N];
long long n, m, a, b;
void read() {
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
}
void dfs(int v, long long &cnt_edges, long long &cnt_vertices) {
  seen[v] = true;
  cnt_vertices++;
  cnt_edges += g[v].size();
  for (int u : g[v]) {
    if (!seen[u]) {
      dfs(u, cnt_edges, cnt_vertices);
    }
  }
}
int main() {
  read();
  for (int i = 1; i <= n; ++i) {
    if (!seen[i]) {
      long long cnt_vertices = 0, cnt_edges = 0;
      dfs(i, cnt_edges, cnt_vertices);
      if (cnt_edges != cnt_vertices * (cnt_vertices - 1)) {
        cout << "NO" << endl;
        return 0;
      }
    }
  }
  cout << "YES" << endl;
}
