#include <bits/stdc++.h>
using namespace std;
const long long int N = 150005;
vector<long long int> adj[N];
long long int deg[N];
bool vis[N];
vector<long long int> component;
void dfs(long long int s) {
  vis[s] = true;
  component.push_back(s);
  for (auto i : adj[s]) {
    if (!vis[i]) {
      dfs(i);
    }
  }
}
void solve() {
  long long int n, m;
  cin >> n >> m;
  for (long long int i = 0; i < m; i++) {
    long long int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
    deg[u]++;
    deg[v]++;
  }
  for (long long int i = 1; i <= n; i++) {
    if (!vis[i]) {
      component.clear();
      dfs(i);
    }
    long long int edgesCnt = 0;
    for (auto j : component) {
      edgesCnt += deg[j];
    }
    edgesCnt /= 2;
    long long int componentSize = component.size();
    long long int reqCnt = (componentSize * (componentSize - 1)) / 2;
    if (edgesCnt != reqCnt) {
      cout << "NO"
           << "\n";
      return;
    }
  }
  cout << "YES"
       << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
  return 0;
}
