#include <bits/stdc++.h>
using namespace std;
template <class T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
const int maxn = 150150;
vector<int> a[maxn];
bool f[maxn];
int b[maxn], l, n, m, u, v;
void solve() {
  scanf("%d %d", &n, &m);
  for (int i = 0, u, v; i < m; ++i) {
    scanf("%d %d", &u, &v);
    a[u].push_back(v);
    a[v].push_back(u);
  }
  for (int i = 1; i <= n; ++i) {
    if (!f[i]) {
      f[i] = true;
      l = 0;
      b[l++] = i;
      for (int j = 0; j < l; j++) {
        u = b[j];
        for (int c = 0; c < a[u].size(); c++)
          if (f[a[u][c]] == false) {
            f[a[u][c]] = true;
            b[l++] = a[u][c];
          }
      }
      for (int j = 0; j < l; j++)
        if (a[b[j]].size() != l - 1) {
          puts("NO");
          return;
        }
    }
  }
  puts("YES");
}
int main() {
  int t = 1;
  while (t--) {
    solve();
  }
  for (int i = 0; i < 1; i++)
    ;
}
