#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> v[150001];
bool vis[150001];
stack<int> s1;
void dfs(int s) {
  vis[s] = 1;
  for (int u : v[s]) {
    if (!vis[u]) dfs(u);
  }
  s1.push(s);
}
int main() {
  cin >> n >> m;
  int x, y;
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  memset(vis, 0, sizeof(vis));
  int flg = 1;
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      dfs(i);
      int sz = s1.size() - 1;
      while (!s1.empty()) {
        int d = s1.top();
        s1.pop();
        if (v[d].size() != sz) {
          flg = 0;
          break;
        }
      }
      if (!flg) break;
    }
  }
  if (flg)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
