#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> v[200000], w;
bool vis[200000] = {0};
void dfs(int x) {
  vis[x] = 1;
  w.push_back(x);
  for (auto i : v[x]) {
    if (!vis[i]) dfs(i);
  }
}
int main() {
  int i, a, b;
  bool y = 1;
  cin >> n >> m;
  for (i = 1; i <= m; i++) {
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  for (i = 1; i <= n; i++) {
    if (vis[i]) continue;
    dfs(i);
    for (auto j : w) {
      if (v[i].size() == v[j].size()) continue;
      y = 0;
      break;
    }
    y &= (v[i].size() == w.size() - 1);
    if (!y) break;
    w.clear();
  }
  cout << (y ? "YES" : "NO") << endl;
}
