#include <bits/stdc++.h>
using namespace std;
const int MAX = 1.5e5 + 1;
vector<int> g[MAX];
bool used[MAX] = {};
int N;
bool dfs(int v) {
  N++;
  used[v] = 1;
  bool ans = 1;
  int S = g[v].size();
  for (auto to : g[v]) {
    if (!used[to]) dfs(to);
    ans &= (S == g[to].size());
  }
  if (S != N - 1) ans = 0;
  return ans;
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0, u, v; i < m; i++) {
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  bool ans = 1;
  for (int i = 1; i <= n; i++) {
    N = 0;
    if (!used[i]) ans &= dfs(i);
  }
  cout << (ans ? "YES" : "NO");
  return 0;
}
