#include <bits/stdc++.h>
using namespace std;
const int max_n = 2 * (1e5) + 10;
int h[max_n];
int ans[max_n];
int num = 0;
int vis[max_n], v[max_n];
int pd;
int n;
struct Edge {
  int u, v;
  int next;
} e[max_n * 2];
void add_edge(int u, int v) {
  e[num].u = u;
  e[num].v = v;
  e[num].next = h[u];
  h[u] = num++;
}
int bfs(int u) {
  queue<int> q;
  vis[u] = 1;
  for (int i = h[u]; i != -1; i = e[i].next) {
    int v = e[i].v;
    if (!vis[v]) q.push(v), vis[v] = 1;
  }
  while (!q.empty()) {
    u = q.front();
    q.pop();
    for (int i = h[u]; i != -1; i = e[i].next) {
      if (ans[u] != ans[e[i].v]) return 0;
      if (!vis[e[i].v]) return 0;
    }
  }
  return 1;
}
int main() {
  int m;
  while (scanf("%d%d", &n, &m) != EOF) {
    memset(h, -1, sizeof(h));
    memset(ans, 0, sizeof(ans));
    num = 0;
    for (int i = 0; i < m; i++) {
      int u, v;
      scanf("%d%d", &u, &v);
      ans[u]++;
      ans[v]++;
      add_edge(u, v);
      add_edge(v, u);
    }
    int flag = 1;
    for (int i = 1; i <= n; i++) {
      if (!vis[i]) {
        if (bfs(i) == 0) {
          flag = 0;
          break;
        }
      }
    }
    if (flag)
      printf("YES\n");
    else
      printf("NO\n");
  }
}
