#include <bits/stdc++.h>
using namespace std;
long long n, m;
vector<long long> g[150005];
bool vis[150005];
long long nb;
void dfs(long long node) {
  vis[node] = 1;
  nb++;
  for (auto child : g[node]) {
    if (!vis[child]) dfs(child);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  memset(vis, 0, sizeof vis);
  cin >> n >> m;
  long long x, y;
  for (long long i = 0; i < m; i++) {
    cin >> x >> y;
    x--;
    y--;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  x = 0;
  for (long long i = 0; i < n; i++) {
    nb = 0;
    if (!vis[i]) {
      dfs(i);
      x += (((nb - 1) * nb) / 2);
    }
  }
  if (x != m)
    cout << "NO";
  else
    cout << "YES";
}
