#include <bits/stdc++.h>
using namespace std;
long long vis;
int v, e;
const int MAX = 200005;
vector<int> adj[MAX];
bool marked[MAX];
void init() {
  for (int j = 0; j <= v; j++) {
    adj[j].clear();
    marked[j] = 0;
  }
}
vector<long long> che;
static void dfs(int s) {
  marked[s] = 1;
  ++vis;
  che.push_back(s);
  int i, next;
  for (i = 0; i < adj[s].size(); i++) {
    next = adj[s][i];
    if (!marked[next]) dfs(next);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  init();
  long long n, m;
  cin >> n >> m;
  for (int i = 0; i < (int)(m); ++i) {
    long long a, b;
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  bool ok = 1, exit = 0;
  for (int i = 0; i < (int)(n); ++i) {
    if (marked[i]) continue;
    che.clear();
    vis = 0;
    dfs(i);
    for (int j = 0; j < (int)(((int)che.size())); ++j) {
      if (((int)adj[che[j]].size()) != vis - 1) {
        ok = 0;
        exit = 1;
        break;
      }
    }
    if (exit) break;
  }
  cout << (ok ? "YES" : "NO") << '\n';
  return 0;
}
