#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5;
char maps[100][100];
long long m, n, p[maxn], v[maxn], s[maxn];
string ans = "YES";
int finds(int x) {
  if (p[x] != x) p[x] = finds(p[x]);
  return p[x];
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) p[i] = i, v[i] = 1;
  long long a, b;
  while (m--) {
    cin >> a >> b;
    long long id1 = finds(a), id2 = finds(b);
    if (id1 != id2) {
      p[id2] = id1;
      s[id1] += s[id2];
      v[id1] += v[id2];
    }
    s[id1]++;
  }
  for (int i = 1; i <= n; i++) {
    long long t = finds(i);
    if (v[t] * (v[t] - 1) / 2 != s[t]) {
      ans = "NO";
      break;
    }
  }
  cout << ans << endl;
  return 0;
}
