#include <bits/stdc++.h>
using namespace std;
long long ver = 0;
long long ribs = 0;
int n, m;
vector<char> used;
vector<vector<int>> g;
void dfs(int ind) {
  used[ind] = true;
  ver++;
  ribs += g[ind].size();
  for (int i = 0; i < g[ind].size(); ++i) {
    if (!used[g[ind][i]]) {
      dfs(g[ind][i]);
    }
  }
}
int main() {
  cin >> n >> m;
  used.resize(n + 1);
  g.resize(n + 1);
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  for (int i = 1; i <= n; ++i) {
    if (!used[i]) dfs(i);
    if (ribs != ver * (ver - 1)) {
      cout << "NO";
      return 0;
    }
    ver = 0;
    ribs = 0;
  }
  cout << "YES";
  return 0;
}
