#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<vector<int> > adj(n);
  int m;
  cin >> m;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  vector<int> vis(n, 0);
  for (int i = 0; i < n; i++) {
    if (!vis[i]) {
      vis[i] = 1;
      for (int j = 0; j < adj[i].size(); j++) {
        if (adj[adj[i][j]].size() != adj[i].size()) {
          cout << "NO" << endl;
          return 0;
        }
        vis[adj[i][j]] = 1;
      }
      for (int j = 0; j < adj[i].size(); j++) {
        for (int k = 0; k < adj[adj[i][j]].size(); k++) {
          if (!vis[adj[adj[i][j]][k]]) {
            cout << "NO" << endl;
            return 0;
          }
        }
      }
    }
  }
  cout << "YES" << endl;
}
