#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> G[150001];
vector<bool> vis(150001, false);
void dfs(int node, long long& nodes, long long& edges) {
  vis[node] = true;
  ++nodes;
  for (auto it : G[node]) {
    ++edges;
    if (!vis[it]) dfs(it, nodes, edges);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int m;
  cin >> n >> m;
  for (long long i = 0; i < m; ++i) {
    int x, y;
    cin >> x >> y;
    G[x].push_back(y);
    G[y].push_back(x);
  }
  for (int i = 1; i <= n; ++i) {
    if (!vis[i]) {
      long long nodes = 0, edges = 0;
      dfs(i, nodes, edges);
      if (nodes * (nodes - 1) / 2 != edges / 2) {
        cout << "NO\n";
        return 0;
      }
    }
  }
  cout << "YES\n";
  return 0;
}
