#include <bits/stdc++.h>
using namespace std;
long long tt = 0, edge = 0;
bool check[1000000];
vector<long long> vec[1000000];
void dfs(long long i) {
  check[i] = true;
  tt++;
  edge += vec[i].size();
  for (long long j = 0; j < vec[i].size(); j++) {
    if (!check[vec[i][j]]) dfs(vec[i][j]);
  }
}
int main() {
  long long n, m;
  cin >> n >> m;
  while (m--) {
    long long a, b;
    cin >> a >> b;
    vec[a].push_back(b);
    vec[b].push_back(a);
  }
  for (long long i = 1; i <= n; i++) {
    tt = 0, edge = 0;
    if (!check[i]) dfs(i);
    if (tt * (tt - 1) != edge) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}
