#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > adj;
vector<bool> v;
long long edge;
int dfs(int src) {
  v[src] = 1;
  long long p = 1;
  edge += adj[src].size();
  for (int i = 0; i < adj[src].size(); ++i)
    if (!v[adj[src][i]]) {
      p += dfs(adj[src][i]);
    }
  return p;
}
int main() {
  int i, n, m, src = 0;
  scanf("%d", &n), scanf("%d", &m);
  adj.resize(n);
  v.resize(n, 0);
  for (i = 0; i < m; ++i) {
    int x, y;
    scanf("%d", &x), scanf("%d", &y);
    adj[x - 1].push_back(y - 1), adj[y - 1].push_back(x - 1);
  }
  bool f1 = 1;
  for (i = 0; i < n; ++i) {
    if (v[i]) continue;
    edge = 0;
    long long x = dfs(i);
    if (edge != x * (x - 1)) {
      f1 = 0;
      break;
    }
  }
  printf("%s\n", f1 ? "YES" : "NO");
  return 0;
}
