#include <bits/stdc++.h>
using namespace std;
int id[150055];
vector<int> E[150055];
int dd[150055];
int in[150055];
int is = 0;
void dfs(int u) {
  for (int i = 0; i < E[u].size(); i++) {
    int v = E[u][i];
    if (in[v] == 0) {
      id[is]++;
      in[v] = is;
      dfs(v);
    }
  }
}
int main() {
  int N, M;
  cin >> N >> M;
  {
    for (int i = 1; i <= M; i++) {
      int a, b;
      scanf("%d %d", &a, &b);
      E[a].push_back(b);
      E[b].push_back(a);
      dd[a]++;
      dd[b]++;
    }
    memset(in, 0, sizeof(in));
    memset(id, 0, sizeof(id));
    for (int i = 1; i <= N; i++) {
      if (in[i] == 0) {
        is++;
        in[i] = is;
        id[is]++;
        dfs(i);
      }
    }
    for (int i = 1; i <= N; i++) {
      int ins = id[in[i]];
      if (dd[i] != ins - 1) {
        puts("NO");
        return 0;
      }
    }
    puts("YES");
    return 0;
  }
}
