#include <bits/stdc++.h>
using namespace std;
const int N = 15e4 + 10;
const double INF = 1e12;
const double eps = 1e-9;
int n, m;
int cnt[N];
vector<int> adj[N];
int a, b;
long long e, v;
bool visit[N];
void bfs(int x, long long& e, long long& v) {
  queue<int> q;
  q.push(x);
  while (!q.empty()) {
    a = q.front();
    q.pop();
    if (visit[a]) continue;
    e += cnt[a];
    v++;
    visit[a] = true;
    for (int i = 0; i < adj[a].size(); i++) {
      b = adj[a][i];
      if (!visit[b]) q.push(b);
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &a, &b);
    adj[a].push_back(b);
    adj[b].push_back(a);
    cnt[a]++;
    cnt[b]++;
  }
  for (int i = 1; i <= n; i++) {
    if (!visit[i]) {
      e = 0;
      v = 0;
      bfs(i, e, v);
      if (e != v * (v - 1)) return puts("NO");
    }
  }
  puts("YES");
}
