#include <bits/stdc++.h>
using namespace std;
const long double EPS = 1e-9;
const long long MOD = 1e9 + 7;
vector<vector<int> > g;
bool vis[200000];
long long nodes;
long long solve(int node) {
  vis[node] = 1;
  nodes++;
  long long ret = 0;
  for (int i = 0; i < g[node].size(); ++i) {
    int child = g[node][i];
    if (!vis[child]) {
      ret++;
    }
  }
  for (int i = 0; i < g[node].size(); ++i) {
    int child = g[node][i];
    if (!vis[child]) {
      ret += solve(child);
    }
  }
  return ret;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m;
  cin >> n >> m;
  g = vector<vector<int> >(n);
  int x, y;
  for (int i = 0; i < m; ++i) {
    cin >> x >> y;
    g[x - 1].push_back(y - 1);
    g[y - 1].push_back(x - 1);
  }
  bool ans = 1;
  for (int i = 0; i < n; ++i) {
    if (!vis[i]) {
      nodes = 0;
      long long cnt = solve(i);
      ans &= (cnt == (nodes * (nodes - 1)) / 2);
    }
  }
  if (ans)
    cout << "YES";
  else
    cout << "NO";
}
