#include <bits/stdc++.h>
using namespace std;
#pragma GCC push_options
#pragma GCC optimize("unroll-loops")
long long count1 = 0ll;
long long count2 = 0ll;
void dfs(vector<long long> adj[], bool visited[], long long v) {
  visited[v] = true;
  count1++;
  count2 += adj[v].size();
  for (auto x : adj[v]) {
    if (!visited[x]) dfs(adj, visited, x);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, m;
  cin >> n >> m;
  vector<long long> adj[n];
  for (int i = 0; i < m; i++) {
    long long u, v;
    cin >> u >> v;
    adj[u - 1].emplace_back(v - 1);
    adj[v - 1].emplace_back(u - 1);
  }
  bool visited[n];
  memset(visited, false, sizeof(visited));
  bool ans = true;
  for (int i = 0; i < n; i++) {
    if (!visited[i]) {
      dfs(adj, visited, i);
      if (count1 * (count1 - 1) != count2) {
        ans = false;
        break;
      }
      count2 = 0ll;
      count1 = 0ll;
    }
  }
  if (ans)
    cout << "YES\n";
  else
    cout << "NO\n";
  return 0;
}
