#include <bits/stdc++.h>
using namespace std;
string tostr(int n) {
  stringstream rr;
  rr << n;
  return rr.str();
}
long long power(long long a, long long b) {
  return b == 0 ?: a * power(a, b - 1);
}
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); }
int par[150500];
int Size[150500];
int edge[150500];
void Set(int n) {
  for (int i = 1; i <= n; i++) {
    par[i] = i;
    Size[i] = 1;
  }
}
int Find(int x) {
  if (x != par[x])
    return par[x] = Find(par[x]);
  else
    return x;
}
void Union(int a, int b) {
  edge[a]++, edge[b]++;
  int i = Find(a), j = Find(b);
  if (i == j) return;
  if (Size[i] > Size[j]) swap(i, j);
  par[i] = j;
  Size[j] += Size[i];
}
int main() {
  ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  Set(n);
  for (int i = 1; i <= m; i++) {
    int a, b;
    cin >> a >> b;
    Union(a, b);
  }
  bool ok = true;
  for (int i = 1; i <= n; i++)
    if (Size[Find(i)] != edge[i] + 1) ok = false;
  if (ok)
    cout << "YES"
         << "\n";
  else
    cout << "NO"
         << "\n";
  return 0;
}
