#include <bits/stdc++.h>
using namespace std;
const int N = 150009;
bool u[N];
int e;
int c;
vector<int> g[N];
void dfs(int v) {
  u[v] = 1;
  c++;
  e += (int)g[v].size();
  for (int to : g[v]) {
    if (!u[to]) {
      dfs(to);
    }
  }
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    --a, --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  for (int i = 0; i < n; i++) {
    if (!u[i]) {
      e = 0;
      c = 0;
      dfs(i);
      e >>= 1;
      if (e * 1LL != c * 1LL * (c - 1) / 2LL) {
        puts("NO");
        return 0;
      }
    }
  }
  puts("YES");
  return 0;
}
