#include <bits/stdc++.h>
using namespace std;
int visited[1000000] = {0};
vector<vector<int> > g(1000000);
long long vertices = 0, edges = 0;
void dfs(int node) {
  visited[node] = 1;
  vertices++;
  edges += g[node].size();
  for (auto i = g[node].begin(); i != g[node].end(); i++) {
    if (visited[*i] == 0) {
      dfs(*i);
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  int flag = 0;
  for (int i = 1; i <= n; i++) {
    if (visited[i] == 0) {
      edges = 0;
      vertices = 0;
      dfs(i);
      if (vertices * (vertices - 1) != edges) {
        cout << "NO\n";
        return 0;
      }
    }
  }
  cout << "YES\n";
  return 0;
}
