#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
vector<int> gr[N];
int used[N], usedo[N];
int len = 0, fl = 0;
void dfs(int v) {
  len++;
  used[v] = 1;
  for (auto e : gr[v]) {
    if (!used[e]) dfs(e);
  }
}
void dfso(int v) {
  usedo[v] = 1;
  if (gr[v].size() != len - 1) {
    fl = 0;
    return;
  }
  for (auto e : gr[v]) {
    if (!usedo[e]) dfso(e);
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    gr[u].push_back(v);
    gr[v].push_back(u);
  }
  int cnt = 0;
  for (int i = 1; i < n + 1; i++) {
    len = 0;
    fl = 1;
    if (!used[i]) {
      dfs(i);
      dfso(i);
      if (!fl) {
        cout << "NO";
        return 0;
      }
    }
  }
  cout << "YES";
  return 0;
}
