#include <bits/stdc++.h>
using namespace std;
const int maxInt = 1e9 * 2;
const long long int maxLong = 1e18 * 2;
bool visited[150112];
vector<int> vct[150123];
int n, m;
int cnt, edges;
void DFS(int vertex) {
  visited[vertex] = 1;
  cnt++;
  edges += vct[vertex].size();
  for (unsigned i = 0; i < vct[vertex].size(); i++) {
    if (!visited[vct[vertex][i]]) {
      DFS(vct[vertex][i]);
    };
  }
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    vct[a].push_back(b);
    vct[b].push_back(a);
  }
  for (int i = 1; i <= n; i++) {
    if (!visited[i]) {
      cnt = 0;
      edges = 0;
      DFS(i);
      if (edges != ((long long)cnt * (cnt - 1))) return cout << "NO", 0;
    }
  }
  return cout << "YES", 0;
}
