#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<vector<int> > e;
int gr[200111], ngr = 0;
int sizegr[200111], ned[200111];
void dfs(int u) {
  if (gr[u] == 0) gr[u] = ++ngr;
  sizegr[gr[u]]++;
  for (int i = 0; i < e[u].size(); i++) {
    int v = e[u][i];
    if (gr[v] == 0) {
      gr[v] = gr[u];
      dfs(v);
    }
  }
}
int main() {
  cin >> n >> m;
  e.assign(n, vector<int>());
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    e[u].push_back(v);
    e[v].push_back(u);
  }
  for (int i = 0; i < n; i++) {
    if (gr[i] == 0) {
      dfs(i);
    }
  }
  for (int i = 0; i < n; i++) {
    ned[gr[i]] += e[i].size();
  }
  for (int i = 1; i <= ngr; i++) {
    ned[i] /= 2;
    long long tmp = ((long long)sizegr[i] * (sizegr[i] - 1)) / 2;
    if (ned[i] != tmp) {
      cout << "NO";
      return 0;
    };
  }
  cout << "YES";
  return 0;
}
