#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e6 + 6;
vector<int> adj[MAX];
bool visited[MAX];
void dfs(int source, int &nodes, int &total) {
  total += adj[source].size();
  visited[source] = true;
  nodes++;
  for (auto &each : adj[source]) {
    if (!visited[each]) {
      dfs(each, nodes, total);
    }
  }
}
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = int(0); i < int(m); i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  for (int i = int(1); i < int(n + 1); i++) {
    if (!visited[i]) {
      int total = 0;
      int nodes = 0;
      dfs(i, nodes, total);
      if (total != (1LL * nodes * (nodes - 1))) {
        puts("NO");
        return 0;
      }
    }
  }
  puts("YES");
  return 0;
}
