#include <bits/stdc++.h>
using namespace std;
vector<int> temp;
vector<vector<int> > graph(150001, temp);
int check[150001];
void dfs(int color, int node) {
  check[node] = color;
  for (int j = 0; j < int(graph[node].size()); j++) {
    if (!(graph[graph[node][j]].empty()) && check[graph[node][j]] == 0)
      dfs(color, graph[node][j]);
  }
}
int main() {
  int n, m, x, y;
  scanf("%d", &n);
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    scanf("%d", &x);
    scanf("%d", &y);
    graph[x].push_back(y);
    graph[y].push_back(x);
  }
  int color = 1, flag = 0;
  for (int i = 0; i < 150001; i++) check[i] = 0;
  for (int i = 1; i < n + 1; i++) {
    if (check[i] == 0) {
      if (!(graph[i].empty())) {
        dfs(color, i);
      } else
        check[i] = color;
      color++;
    }
  }
  long long nodecount[color], edgecount[color];
  for (int i = 0; i < color; i++) {
    nodecount[i] = 0;
    edgecount[i] = 0;
  }
  for (int i = 1; i < n + 1; i++) {
    nodecount[check[i]]++;
    edgecount[check[i]] += graph[i].size();
  }
  for (int i = 0; i < color; i++) {
    if (edgecount[i] != (nodecount[i] * (nodecount[i] - 1))) {
      flag = 1;
      break;
    }
  }
  if (flag == 0)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
