#include <bits/stdc++.h>
const long long int INF = 9999999999999999, MOD = 1e9 + 7, MAXN = 10000;
const long double EPS = 0.000000000001;
using namespace std;
vector<long long int> graph[150040];
bool used[150040];
long long int rebra = 0, ver = 0;
void dfs(long long int v) {
  used[v] = 1;
  ver++;
  for (auto it : graph[v]) {
    if (!used[it]) {
      dfs(it);
    }
    rebra++;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  long long int n;
  cin >> n;
  for (long long int i = 0; i < n; i++) {
    used[i] = 0;
  }
  long long int m;
  cin >> m;
  for (long long int i = 0; i < m; i++) {
    long long int a, b;
    cin >> a >> b;
    a--, b--;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  for (long long int i = 0; i < n; i++) {
    ver = 0, rebra = 0;
    if (!used[i]) {
      dfs(i);
      if ((ver * (ver - 1)) != rebra) {
        cout << "NO\n";
        return 0;
      }
    }
  }
  cout << "YES\n";
  return 0;
}
