#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const int Max = 150009;
vector<int> node[Max];
int vis[Max], flag;
void dfs(int a, int &vertice, int &edge) {
  if (vis[a]) return;
  vertice++;
  edge += node[a].size();
  vis[a] = 1;
  for (int i = 0; i < node[a].size(); i++) {
    int t1 = node[a][i];
    if (!vis[t1]) {
      dfs(t1, vertice, edge);
    }
  }
}
int main(void) {
  int n, m;
  while (~scanf("%d%d", &n, &m)) {
    for (int i = 1; i <= n; i++) node[i].clear();
    for (int i = 0; i < m; i++) {
      int t1, t2;
      scanf("%d%d", &t1, &t2);
      node[t1].push_back(t2);
      node[t2].push_back(t1);
    }
    memset(vis, 0, sizeof vis);
    flag = 1;
    for (int i = 1; i <= n; i++) {
      if (vis[i]) continue;
      int vertice = 0, edge = 0;
      dfs(i, vertice, edge);
      if (edge != (long long)vertice * (vertice - 1)) {
        flag = 0;
        break;
      }
    }
    if (flag)
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}
