#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
int mod = 1000000007;
struct custom_hash {
  static uint64_t splitmix64(uint64_t x) {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM =
        chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};
int par[150005];
int rk[150005];
int deg[150005];
int find(int x) {
  if (x == par[x])
    return x;
  else {
    par[x] = find(par[x]);
    return par[x];
  }
}
void uno(int a, int b) {
  int x = find(a);
  int y = find(b);
  if (x == y) return;
  if (rk[x] >= rk[y]) {
    par[y] = x;
    rk[x] += rk[y];
  } else {
    par[x] = y;
    rk[y] += rk[x];
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  int i, j;
  for (i = 0; i <= n; i++) {
    deg[i] = 0;
    par[i] = i;
    rk[i] = 1;
  }
  for (i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    deg[u]++;
    deg[v]++;
    uno(u, v);
  }
  for (i = 1; i <= n; i++) {
    int x = find(i);
    if (deg[i] != rk[x] - 1) {
      cout << "NO"
           << "\n";
      return 0;
    }
  }
  cout << "YES"
       << "\n";
  return 0;
}
