#include <bits/stdc++.h>
using namespace std;
vector<int> x[150005];
bool d[150005];
int edges = 0;
int dfs(int src, int &edges) {
  int count = 0;
  if (d[src]) {
    return 0;
  }
  d[src] = 1;
  edges += x[src].size();
  count += 1;
  for (auto i : x[src]) count += dfs(i, edges);
  return count;
}
int main() {
  memset(d, 0, 150005);
  int i, n, e, val1, val2;
  cin >> n >> e;
  bool check = false;
  for (i = 0; i < e; i++) {
    cin >> val1 >> val2;
    x[val1].push_back(val2);
    x[val2].push_back(val1);
  }
  for (i = 1; i <= n; i++) {
    if (!d[i]) {
      int edges = 0;
      int ans = dfs(i, edges);
      if ((long long)ans * (ans - 1) != edges) {
        cout << "NO";
        return 0;
      }
    }
  }
  cout << "YES";
  return 0;
}
