#include <bits/stdc++.h>
int power(int x, unsigned int y) {
  int res = 1;
  while (y > 0) {
    if (y & 1) {
      res = res * x;
    }
    y = y >> 1;
    x = x * x;
  }
  return res;
}
int powermod(int x, unsigned int y, int p) {
  int res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) {
      res = (res * x) % p;
    }
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
using namespace std;
string convertupper(string s) {
  transform(s.begin(), s.end(), s.begin(), ::toupper);
  return s;
}
string convertlower(string s) {
  transform(s.begin(), s.end(), s.begin(), ::tolower);
  return s;
}
vector<long long> g[1500005];
map<long long, bool> visited;
long long edges = 0, vertex = 0;
void dfs(long long src) {
  visited[src] = 1;
  vertex++;
  edges += g[src].size();
  for (auto i : g[src]) {
    if (visited[i] == 0) {
      dfs(i);
    }
  }
}
int32_t main() {
  long long n, m;
  cin >> n >> m;
  while (m--) {
    long long u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  for (long long i = 1; i <= n; i++) {
    if (visited[i] == 0) {
      edges = 0, vertex = 0;
      dfs(i);
      edges /= 2;
      if (edges != (vertex * (vertex - 1)) / 2) {
        cout << "NO\n";
        return 0;
      }
    }
  }
  cout << "YES";
  return 0;
}
