#include <bits/stdc++.h>
using namespace std;
bool check = true;
const int maxn = 270502;
bool ok[maxn];
std::vector<std::vector<int> > edge(maxn);
void dfs(int u, long long int &v, long long int &k) {
  ok[u] = true;
  v++;
  k += edge[u].size();
  for (int i = 0; i < edge[u].size(); i++) {
    if (ok[edge[u][i]] == false) {
      dfs(edge[u][i], v, k);
    }
  }
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    edge[u].push_back(v);
    edge[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) {
    if (ok[i] == false) {
      long long int v = 0, k = 0;
      dfs(i, v, k);
      if (k != v * (v - 1)) check = false;
    }
  }
  if (check)
    cout << "YES";
  else
    cout << "NO";
}
