#include <bits/stdc++.h>
using namespace std;
vector<bool> vis(150010, false);
vector<long long> g[150010];
void dfs(int a, int& cnt_v, int& cnt_e) {
  if (vis[a]) return;
  vis[a] = true;
  cnt_v++;
  cnt_e += g[a].size();
  for (int i = 0; i < g[a].size(); i++) {
    if (!vis[g[a][i]]) dfs(g[a][i], cnt_v, cnt_e);
  }
}
int main() {
  long long n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int ai, bi;
    cin >> ai >> bi;
    ai--;
    bi--;
    g[ai].push_back(bi);
    g[bi].push_back(ai);
  }
  for (int i = 0; i < n; i++) {
    if (!vis[i]) {
      int cnt_v = 0, cnt_e = 0;
      dfs(i, cnt_v, cnt_e);
      if (cnt_e != (long long)cnt_v * (cnt_v - 1)) {
        cout << "NO" << endl;
        return 0;
      }
    }
  }
  cout << "YES" << endl;
}
