#include <bits/stdc++.h>
using namespace std;
const int N = 2e5;
vector<vector<int> > adj(N + 1);
vector<bool> vis(N + 1);
long long ver, edg;
bool ok = true;
void DFS(int v, int p) {
  vis[v] = 1;
  ver++;
  for (int j = 0; j < adj[v].size(); j++) {
    edg++;
    int u = adj[v][j];
    if (u == p) continue;
    if (vis[u] == 0) DFS(u, v);
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    adj[v].push_back(u);
    adj[u].push_back(v);
  }
  for (int i = 1; i <= n; i++) {
    if (vis[i] == 0) {
      ver = 0, edg = 0;
      DFS(i, 0);
      ok = ok & (edg == ver * (ver - 1));
    }
  }
  if (ok)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
