#include <bits/stdc++.h>
using namespace std;
const int MAX = 150005;
int par[MAX], ge[MAX], num[MAX];
int find(int x) {
  if (x == par[x])
    return x;
  else
    return par[x] = find(par[x]);
}
void init(int n) {
  for (int i = 1; i <= n; i++) {
    par[i] = i;
    ge[i] = 0;
    num[i] = 1;
  }
}
void unite(int x, int y) {
  ge[x]++;
  ge[y]++;
  x = find(x);
  y = find(y);
  if (x == y) return;
  if (num[x] > num[y]) {
    par[y] = x;
    num[x] += num[y];
    num[y] = 0;
  } else {
    par[x] = y;
    num[y] += num[x];
    num[x] = 0;
  }
}
int n, m;
int x, y;
int main() {
  scanf("%d%d", &n, &m);
  init(n);
  while (m--) {
    scanf("%d%d", &x, &y);
    if (x == y) {
      printf("NO\n");
      return 0;
    } else
      unite(x, y);
  }
  for (int i = 1; i <= n; i++) {
    x = find(i);
    if (ge[i] != num[x] - 1) {
      printf("NO\n");
      return 0;
    }
  }
  printf("YES\n");
  return 0;
}
