#include <bits/stdc++.h>
using namespace std;
bool vis[150001];
long long n, m, a, b, e, nn;
vector<vector<int> > v;
void dfs(int node) {
  nn++, e += v[node].size(), vis[node] = 1;
  for (auto i : v[node])
    if (!vis[i]) dfs(i);
}
int main() {
  cin >> n >> m;
  v.resize(n + 5);
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      e = 0, nn = 0, dfs(i), e /= 2;
      if ((nn * (nn - 1)) / 2 != e) {
        cout << "NO\n";
        return 0;
      }
    }
  }
  cout << "YES\n";
  return 0;
}
