#include <bits/stdc++.h>
using namespace std;
bool vis[150005];
vector<int> g[150005];
long long CN, CE;
void dfs(int n) {
  if (vis[n]) return;
  vis[n] = 1;
  int len = g[n].size();
  CN++;
  for (int i = 0; i < len; i++) {
    dfs(g[n][i]);
    CE++;
  }
}
int main() {
  ios::sync_with_stdio(0);
  int n, m, u, v;
  cin >> n >> m;
  while (m--) {
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) {
    if (vis[i] == 0) {
      CN = CE = 0;
      dfs(i);
      CE /= 2;
      if (CN == 1 || (CN == 2 && CE == 1))
        continue;
      else if (CE != (CN * (CN - 1) / 2)) {
        cout << "NO\n";
        return 0;
      }
    }
  }
  cout << "YES\n";
  return 0;
}
