#include <bits/stdc++.h>
using namespace std;
vector<long long> graph[150005];
long long vis[150005];
void dfs(long long node, long long &v, long long &d) {
  vis[node] = 1;
  v++;
  d += graph[node].size();
  for (long long i = 0; i < graph[node].size(); i++) {
    long long curr = graph[node][i];
    if (vis[curr] != 1) dfs(curr, v, d);
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long test, i, j, l, r;
  long long n, m, e, v, a, b;
  cin >> n >> m;
  for (long long i = 0; i < m; ++i) {
    cin >> a >> b;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  bool flag = 1;
  for (i = 1; i <= n; i++) {
    if (vis[i] != 1) {
      long long v = 0, d = 0, e;
      dfs(i, v, d);
      e = v * (v - 1) / 2;
      if (d / 2 != e) {
        flag = 0;
        break;
      }
    }
  }
  if (flag)
    cout << "YES"
         << "\n";
  else
    cout << "NO"
         << "\n";
}
