#include <bits/stdc++.h>
using namespace std;
int n, m, a, b;
vector<int> v[150000 + 10];
int visited[150000 + 10];
long long dfs(int idx) {
  a++;
  long long ret = v[idx].size();
  for (auto it : v[idx]) {
    if (visited[it]) continue;
    visited[it] = 1;
    ret += dfs(it);
  }
  return ret;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &a, &b);
    v[a].push_back(b);
    v[b].push_back(a);
  }
  for (int i = 1; i <= n; i++) {
    if (visited[i]) continue;
    visited[i] = 1;
    a = 0;
    if (dfs(i) != (long long)a * (long long)(a - 1)) {
      printf("NO");
      return 0;
    }
  }
  printf("YES");
}
