#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> friends(n + 1);
  vector<bool> visited(n + 1, false);
  for (int i = 0; i < m; ++i) {
    int f1, f2;
    cin >> f1 >> f2;
    friends[f1].push_back(f2);
    friends[f2].push_back(f1);
  }
  for (int i = 1; i <= n; ++i) {
    if (visited[i]) {
      continue;
    }
    map<int, int> m;
    for (int f : friends[i]) {
      visited[f] = true;
      m[f]++;
      if (friends[f].size() != friends[i].size()) {
        cout << "NO";
        return 0;
      }
      for (int ff : friends[f]) {
        m[ff]++;
      }
    }
    for (auto mm : m) {
      if (mm.second != friends[i].size()) {
        cout << "NO";
        return 0;
      }
    }
  }
  cout << "YES";
  return 0;
}
