#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
int p[N], du[N], dv[N], ok[N];
int find(int x) { return (p[x] == x) ? x : p[x] = find(p[x]); }
int main() {
  int ver, ne;
  cin >> ver >> ne;
  for (int i = 1; i <= ver; i++) p[i] = i;
  int x, y;
  for (int i = 0; i < ne; i++) {
    cin >> x >> y;
    p[find(x)] = find(y);
    du[x]++;
    du[y]++;
  }
  for (int i = 1; i <= ver; i++) ok[find(i)]++;
  for (int i = 1; i <= ver; i++) {
    if (du[i] != ok[find(i)] - 1) return cout << "NO", 0;
  }
  cout << "YES";
  return 0;
}
