#include <bits/stdc++.h>
using namespace std;
int temp = 99999999, cal = 0;
int n, m;
bool v[200009];
vector<int> g[200009];
void dfs(int a, int b) {
  if (!v[a]) {
    cal++;
    v[a] = true;
  }
  for (int i = 0; i < g[a].size(); i++) {
    int u = g[a][i];
    if (u == b) continue;
    if (!v[u]) dfs(u, a);
  }
  int uu = g[a].size();
  temp = min(temp, uu);
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    g[a].push_back(b);
    g[b].push_back(a);
  }
  bool f = false;
  for (int i = 1; i <= n; i++) {
    temp = 99999999, cal = 0;
    if (!v[i]) {
      dfs(i, i);
      if (temp < cal - 1) {
        f = true;
      }
    }
  }
  if (f)
    printf("NO\n");
  else
    printf("YES\n");
  return 0;
}
