#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, x, y;
  cin >> n >> m;
  vector<int> deg(n, 0), uf(n), uf_cnt(n, 1);
  for (int i = 0; i < n; ++i) uf[i] = i;
  for (int i = 0; i < m; ++i) {
    cin >> x >> y;
    deg[--x]++;
    deg[--y]++;
    while (x != uf[x]) x = uf[x];
    while (y != uf[y]) y = uf[y];
    if (x < y) {
      uf_cnt[x] += uf_cnt[y];
      uf_cnt[y] = 0;
      uf[y] = x;
    }
    if (y < x) {
      uf_cnt[y] += uf_cnt[x];
      uf_cnt[x] = 0;
      uf[x] = y;
    }
  }
  for (int i = 0; i < n; ++i) {
    int j = i;
    while (j != uf[j]) j = uf[j];
    if (deg[i] + 1 != uf_cnt[j]) {
      cout << "NO\n";
      return 0;
    }
  }
  cout << "YES\n";
  return 0;
}
