#include <bits/stdc++.h>
using namespace std;
int fa[150010], point[150010], cmp[150010], n, k;
int find_fa(int x) { return fa[x] == x ? x : fa[x] = find_fa(fa[x]); }
void mix_fa(int x, int y) {
  int fx = find_fa(x), fy = find_fa(y);
  fa[fx] = fy;
}
int main() {
  int n, k, a, b;
  scanf("%d %d", &n, &k);
  for (int i = 1; i <= n; i++) {
    fa[i] = i;
    point[i] = cmp[i] = 0;
  }
  for (int i = 0; i < k; i++) {
    scanf("%d %d", &a, &b);
    point[a]++;
    point[b]++;
    mix_fa(a, b);
  }
  for (int i = 1; i <= n; i++) cmp[find_fa(i)]++;
  bool flag = true;
  for (int i = 1; i <= n; i++)
    if (point[i] + 1 != cmp[find_fa(i)]) {
      flag = false;
      break;
    }
  if (flag)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
