#include <bits/stdc++.h>
using namespace std;
const int inf = INT_MAX;
const int mod = 1e9 + 7;
const int N = 150123;
vector<long long> adj[N];
vector<long long> vis(N, 0);
long long c_ver, c_ed;
void dfs(long long node, long long &c_ver, long long &c_ed) {
  vis[node] = 1;
  c_ver++;
  c_ed += adj[node].size();
  for (auto x : adj[node])
    if (!vis[x]) dfs(x, c_ver, c_ed);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, m;
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    long long x, y;
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  for (long long i = 1; i <= n; i++) {
    if (!vis[i]) {
      long long c_ver = 0, c_ed = 0;
      dfs(i, c_ver, c_ed);
      if (c_ed != c_ver * (c_ver - 1)) {
        cout << "NO";
        return 0;
      }
    }
  }
  cout << "YES";
  return 0;
}
