#include <bits/stdc++.h>
using namespace std;
struct graph {
  long long len, deg;
  bool visited;
  vector<long long> nbr;
  graph() {
    deg = 1;
    len = 0;
    visited = false;
  }
};
void app_dfs(graph *node, long long root, long long id, long long *idv) {
  for (long long i = 0; i < node[root].len; i += 1) {
    long long x = node[root].nbr[i];
    node[x].deg++;
    if (node[x].visited == false) {
      node[x].visited = true;
      idv[x] = id;
      app_dfs(node, x, id, idv);
    }
  }
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, m, v, u;
  cin >> n >> m;
  graph node[n + 1];
  for (long long i = 0; i < m; i += 1) {
    cin >> v >> u;
    node[v].nbr.push_back(u);
    node[u].nbr.push_back(v);
    node[v].len++;
    node[u].len++;
  }
  long long idv[n + 1], id = 1;
  for (long long i = 1; i < n + 1; i += 1) {
    if (node[i].visited == false) {
      node[i].visited = true;
      idv[i] = id;
      app_dfs(node, i, id, idv);
      id++;
    }
  }
  long long num_cnt[id];
  for (long long i = 0; i < id; i += 1) num_cnt[i] = 0;
  for (long long i = 1; i < n + 1; i += 1) {
    num_cnt[idv[i]]++;
  }
  bool poss = true;
  for (long long i = 1; i < n + 1; i += 1) {
    if (node[i].deg != num_cnt[idv[i]]) {
      poss = false;
      break;
    }
  }
  if (poss == true)
    cout << "YES";
  else
    cout << "NO";
}
