#include <bits/stdc++.h>
using namespace std;
const int maxn = 150005;
vector<int> g[maxn], v(maxn);
int n, m;
int d[maxn];
vector<int> b;
void dfs(int x) {
  v[x] = true;
  b.push_back(x);
  for (auto y : g[x]) {
    if (!v[y]) {
      dfs(y);
    }
  }
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    int x, y;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
    d[x]++;
    d[y]++;
  }
  for (int i = 1; i <= n; ++i) {
    b.clear();
    if (!v[i]) {
      dfs(i);
      long long s = b.size(), r = 0;
      for (auto x : b) {
        r += d[x];
      }
      if (s * (s - 1) != r) {
        cout << "NO" << endl;
        return 0;
      }
    }
  }
  cout << "YES" << endl;
  return 0;
}
