#include <bits/stdc++.h>
using namespace std;
vector<long long int> v[200005], ans;
int vis[200005];
void dfs(int r) {
  vis[r] = 1;
  ans.push_back(r);
  for (int x = 0; x < v[r].size(); x++) {
    if (!vis[v[r][x]]) {
      dfs(v[r][x]);
    }
  }
}
int main() {
  long long int a, b;
  cin >> a >> b;
  for (int x = 0; x < b; x++) {
    long long int p, q;
    cin >> p >> q;
    v[p].push_back(q);
    v[q].push_back(p);
  }
  int f = 1;
  for (int x = 1; x <= a; x++) {
    if (!vis[x]) {
      dfs(x);
      long long int count = 0;
      for (int x = 0; x < ans.size(); x++) {
        count += v[ans[x]].size();
      }
      if (count !=
          (long long int)ans.size() * ((long long int)ans.size() - 1)) {
        f = -1;
        break;
      }
      ans.clear();
    }
  }
  if (f == -1) {
    cout << "NO";
  } else {
    cout << "YES";
  }
}
