#include <bits/stdc++.h>
using namespace std;
int vis[200005], dis[200005], n, m;
vector<int> adj[200005];
void dfs(int s, int &v, int &edge) {
  vis[s] = 1;
  v++;
  edge += adj[s].size();
  for (int i = 0; i < adj[s].size(); i++) {
    if (vis[adj[s][i]] == 0) dfs(adj[s][i], v, edge);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t = 1;
  while (t--) {
    int n, m;
    cin >> n >> m;
    for (int i = 0, x, y; i < m; i++) {
      cin >> x >> y;
      adj[x].push_back(y);
      adj[y].push_back(x);
    }
    for (int i = 1, v, edge; i <= n; i++) {
      if (vis[i] == 0) {
        edge = 0;
        v = 0;
        dfs(i, v, edge);
        if (edge != (long long)v * (v - 1)) {
          cout << "NO" << endl;
          return 0;
        }
      }
    }
    cout << "YES" << endl;
  }
}
