#include <bits/stdc++.h>
using namespace std;
long long x, y, nr, n, m, c[150001], b[150001], t[150001];
vector<int> v[150001];
queue<int> q;
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
    c[x]++;
    c[y]++;
  }
  nr = 1;
  for (int i = 1; i <= n; i++) {
    if (!b[i]) {
      q.push(i);
      while (!q.empty()) {
        int x = q.front();
        q.pop();
        if (!b[x]) {
          b[x] = nr;
          t[nr]++;
          for (int j = 0; j < v[x].size(); j++) {
            if (!b[v[x][j]]) {
              q.push(v[x][j]);
            }
          }
        }
      }
      nr++;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (c[i] != t[b[i]] - 1) {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES";
}
