#include <bits/stdc++.h>
using namespace std;
vector<int> grafo[300000];
bool chegou[300000];
vector<int> passou;
int n, m;
void dfs(int v) {
  chegou[v] = true;
  passou.push_back(v);
  for (int i = 0; i < grafo[v].size(); i++) {
    int adj = grafo[v][i];
    if (!chegou[adj]) {
      dfs(adj);
    }
  }
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    grafo[a].push_back(b);
    grafo[b].push_back(a);
  }
  for (int i = 1; i <= n; i++) {
    if (!chegou[i]) {
      dfs(i);
      int mini = passou.size() - 1;
      for (int c = 0; c < passou.size(); c++) {
        if (grafo[passou[c]].size() < mini) {
          cout << "NO\n";
          return 0;
        }
      }
      passou.clear();
    }
  }
  cout << "YES\n";
  return 0;
}
