#include <bits/stdc++.h>
using namespace std;
const int INF = 2147483647;
const string no = "NO", yes = "YES";
void solve();
void testcase();
long long Eps(int kol) {
  long long a = 1;
  for (int(i) = 0; i < (int)(kol); ++i) a *= 10;
  return a;
}
long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
void testcase() {
  cout << "\nTime elapsed: " << clock() / 1000 << " ms" << endl;
}
vector<vector<int> > g;
vector<int> used;
void dfs(int v, long long &a, long long &b) {
  used[v] = 1;
  a++;
  b += g[v].size();
  for (int(i) = 0; i < (int)(g[v].size()); ++i) {
    if (!used[g[v][i]]) {
      dfs(g[v][i], a, b);
    }
  }
}
void solve() {
  int n, m, k;
  cin >> n >> m;
  g.resize(n);
  used.resize(n);
  for (int(i) = 0; i < (int)(m); ++i) {
    int l, r = 0;
    cin >> l >> r;
    l--;
    r--;
    g[l].push_back(r);
    g[r].push_back(l);
  }
  k = 0;
  for (int(i) = 0; i < (int)(n); ++i) {
    if (!used[i]) {
      long long a = 0, b = 0;
      dfs(i, a, b);
      if (a * (a - 1) != b) {
        cout << no;
        return;
      }
    }
  }
  cout << yes;
}
