#include <bits/stdc++.h>
using namespace std;
vector<int> graph[150005];
int n, m, visited[150005];
long long int tot = 0;
int dfs(int src) {
  visited[src] = 1;
  tot += graph[src].size();
  int k = 1;
  for (int i = 0; i < graph[src].size(); ++i) {
    if (!visited[graph[src][i]]) k += dfs(graph[src][i]);
  }
  return k;
}
int main() {
  scanf("%d", &n), scanf("%d", &m);
  for (int i = 0; i < m; ++i) {
    int u, v;
    scanf("%d", &u), scanf("%d", &v);
    graph[u].push_back(v);
    graph[v].push_back(u);
  }
  for (int i = 1; i <= n; ++i) {
    long long int k;
    tot = 0;
    if (!visited[i])
      k = dfs(i);
    else
      continue;
    if (tot != (k * (k - 1))) {
      cout << "NO\n";
      return 0;
    }
  }
  cout << "YES\n";
  return 0;
}
