#include <bits/stdc++.h>
using namespace std;
const long long maxn = 150000 + 10;
long long n, m, k, t, t1;
long long vis[maxn];
map<long long, vector<long long> > p;
void bfs(long long u) {
  k++;
  vis[u] = 1;
  for (int i = 0; i < p[u].size(); i++) {
    if (!vis[p[u][i]]) bfs(p[u][i]);
  }
}
int main() {
  scanf("%lld%lld", &n, &m);
  for (long long i = 0; i < m; i++) {
    scanf("%lld%lld", &t, &t1);
    p[t1].push_back(t);
    p[t].push_back(t1);
  }
  long long sum = 0;
  for (auto u : p) {
    if (!vis[u.first]) {
      k = 0;
      bfs(u.first);
      sum = sum + k * (k - 1) / 2;
    }
  }
  printf("%s\n", sum == m ? "YES" : "NO");
  return 0;
}
