#include <bits/stdc++.h>
using namespace std;
const int N = 5 * 1e5 + 10;
const int M = 150;
const int INF = 0x3f3f3f3f;
const int MOD = 998244353;
vector<int> g[N];
bool st[N];
long long res = 0, e = 0;
void dfs(int u, long long &e, long long &res) {
  st[u] = true;
  e++;
  res += g[u].size();
  for (int i = 0; i < g[u].size(); i++) {
    if (!st[g[u][i]]) dfs(g[u][i], e, res);
  }
}
void solve() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  int fg = 1;
  for (int i = 1; i <= n; i++) {
    if (!st[i]) {
      e = 0, res = 0;
      dfs(i, e, res);
      if (res != e * (e - 1)) {
        fg = 0;
      }
    }
  }
  if (!fg)
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ;
  solve();
  return 0;
}
