#include <bits/stdc++.h>
using namespace std;
const int N = 150010;
int n, m;
vector<int> edges[N];
bool vis[N];
void dfs(int u, int &ver, int &edge) {
  vis[u] = true;
  ver++;
  edge += (int)edges[u].size();
  for (int i = 0; i < (int)edges[u].size(); i++) {
    int t = edges[u][i];
    if (!vis[t]) {
      dfs(t, ver, edge);
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    edges[a].push_back(b);
    edges[b].push_back(a);
  }
  bool flag = false;
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      int ver = 0, edge = 0;
      dfs(i, ver, edge);
      edge /= 2;
      if (1ll * ver * (ver - 1) != edge * 2ll) {
        flag = true;
        break;
      }
    }
  }
  if (flag)
    printf("NO\n");
  else
    printf("YES\n");
  return 0;
}
