#include <bits/stdc++.h>
using namespace std;
int p[150010];
int find(int x) { return p[x] == x ? x : p[x] = find(p[x]); }
int n, m;
int cango[150010];
map<int, int> mapa;
map<int, int> mapb;
int main() {
  scanf("%d", &n);
  scanf("%d", &m);
  for (int i = 1; i <= n; i++) {
    p[i] = i;
  }
  int l, r;
  for (int i = 1; i <= m; i++) {
    scanf("%d", &l);
    scanf("%d", &r);
    cango[l]++;
    cango[r]++;
    l = find(l);
    r = find(r);
    p[l] = r;
  }
  for (int i = 1; i <= n; i++) {
    mapb[find(i)]++;
    mapa[find(i)] += cango[i];
  }
  for (auto au : mapa) {
    if (1ll * mapb[au.first] * (mapb[au.first] - 1) != au.second) {
      puts("NO");
      exit(0);
    }
  }
  puts("YES");
  return 0;
}
