#include <bits/stdc++.h>
using namespace std;
vector<long long int> vv[200010];
map<long long int, long long int> maa;
long long int ar[200010];
void dfs(long long int a) {
  long long int i, j, k, b, c, d;
  ar[a] = 1;
  maa[a] = 1;
  for (i = 0; i < vv[a].size(); i++) {
    if (ar[vv[a][i]] == 0) {
      ar[vv[a][i]] == 1;
      dfs(vv[a][i]);
    }
  }
}
int main() {
  long long int i, j, a, k, b, c, n, t, m, p, q, d, e, f, y, g, z, h, r, l, x,
      o;
  long double aa, bb, cc, ee, dd, ff, kk;
  vector<long long int> v, s;
  vector<long long int> ss;
  map<char, vector<long long int> > me;
  map<long long int, long long int> sa, ta, pa, ma;
  priority_queue<long long int> aq, tq, pq;
  string st, et, ft, pt, ct;
  deque<long long int> de, pe, ne;
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (i = 1; i <= m; i++) {
    cin >> a >> b;
    vv[a].push_back(b);
    vv[b].push_back(a);
  }
  f = 0;
  for (i = 1; i <= n; i++) {
    maa.clear();
    if (ar[i] == 0) {
      dfs(i);
      for (auto it = maa.begin(); it != maa.end(); it++) {
        a = (*it).first;
        if (vv[a].size() != maa.size() - 1) {
          f = 1;
          break;
        }
      }
      if (f == 1) break;
      maa.clear();
    }
  }
  if (f == 1)
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
  return 0;
}
