#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const long long linf = 1e18;
const double pi = acos(-1.0);
const int MAXN = 150000 + 10;
const int MAXM = 1e5 + 10;
const double eps = 1e-8;
bool du[MAXN];
vector<int> g[MAXN];
bool vis[MAXN];
int sum;
bool flag;
void dfs(int u, int num) {
  if (!flag) return;
  vis[u] = 1;
  ++sum;
  for (int i = 0; i < g[u].size(); ++i) {
    int v = g[u][i];
    if (vis[v]) continue;
    if (num != g[v].size()) {
      flag = 0;
      return;
    }
    dfs(v, num);
  }
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  while (m--) {
    int u, v;
    scanf("%d%d", &u, &v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  flag = 1;
  for (int i = 1; i <= n; ++i) {
    if (!vis[i]) {
      sum = 0;
      dfs(i, g[i].size());
      if (g[i].size() != sum - 1) flag = 0;
    }
    if (!flag) break;
  }
  puts(flag ? "YES" : "NO");
  return 0;
}
