#include <bits/stdc++.h>
using namespace std;
int n;
long long m;
vector<int> edge[150100];
int cnt_v = 0;
long long cnt_e = 0;
int vis[150100];
void dfs(int u) {
  vis[u] = 1;
  cnt_v++;
  cnt_e += (long long)edge[u].size();
  for (int i = 0; i < edge[u].size(); i++) {
    int v = edge[u][i];
    if (vis[v]) continue;
    dfs(v);
  }
}
int main() {
  scanf("%d%I64d", &n, &m);
  for (long long i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    edge[u].push_back(v);
    edge[v].push_back(u);
  }
  int flag = 0;
  for (int i = 1; i <= n; i++) {
    if (vis[i]) continue;
    dfs(i);
    if (((long long)cnt_v * (cnt_v - 1)) != cnt_e) {
      flag = 1;
      break;
    }
    cnt_v = 0;
    cnt_e = 0;
  }
  if (flag == 1)
    printf("NO\n");
  else
    printf("YES\n");
  return 0;
}
