#include <bits/stdc++.h>
using namespace std;
void FastInputOutput() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
inline int D() {
  int t;
  scanf("%d", &t);
  return t;
}
inline long long LLD() {
  long long t;
  scanf("%lld", &t);
  return t;
}
long long power(long long x, long long p, long long m) {
  long long res = 1;
  while (p) {
    if (p & 1) res = (res * x) % m;
    x = (x * x) % m;
    p >>= 1;
  }
  return res;
}
long double ModLog(long double base, long double x) {
  return (logl(x) / logl(base));
}
const int N = 1e6 + 5, MX = 1e9;
int head[N], to[N], nxt[N], ne;
void addEdge(int u, int v) {
  nxt[ne] = head[u];
  to[ne] = v;
  head[u] = ne++;
}
void addBiEdge(int u, int v) {
  addEdge(u, v);
  addEdge(v, u);
}
void init() { memset(head, -1, sizeof(head)); }
int vst[N], cntNode, cntEdge;
void DFS(int u) {
  vst[u] = 1;
  ++cntNode;
  for (int e = head[u]; ~e; e = nxt[e]) {
    ++cntEdge;
    int v = to[e];
    if (!vst[v]) DFS(v);
  }
}
int main() {
  init();
  int n = D(), m = D();
  for (int i = 0; i < m; ++i) {
    int u = D(), v = D();
    addBiEdge(u, v);
  }
  bool ans = true;
  for (int i = 1; i <= n && ans; ++i) {
    if (!vst[i]) {
      cntEdge = cntNode = 0;
      DFS(i);
      long long ce = (cntNode * 1LL * (cntNode - 1));
      ans &= ce == cntEdge;
    }
  }
  printf(ans ? "YES" : "NO");
  return 0;
}
