#include <bits/stdc++.h>
using namespace std;
vector<int> v[150005];
vector<int> ans;
int vis[150005];
void dfs(int node) {
  if (vis[node]) return;
  vis[node] = 1;
  for (int i = 0; i < v[node].size(); i++) {
    dfs(v[node][i]);
  }
  ans.push_back(node);
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  int flag = 1;
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      ans.clear();
      dfs(i);
      long long int cnt = 0, x = ans.size();
      for (int i = 0; i < ans.size(); i++) {
        cnt += v[ans[i]].size();
      }
      if (cnt != (x * (x - 1))) flag = 0;
    }
  }
  if (flag)
    cout << "YES";
  else
    cout << "NO";
}
