#include <bits/stdc++.h>
using namespace std;
long long GCD(long long a, long long b) { return (b == 0) ? a : GCD(b, a % b); }
bool isPrime(int x) {
  for (int i = 2; i <= sqrt(x); i++)
    if (x % i == 0) return 0;
  return 1;
}
bool vis[150005];
vector<set<int>> v;
bool check(int it, set<int> s, int i) {
  s.erase(it);
  s.insert(i);
  return (s == v[it]);
}
int main() {
  int n, m;
  cin >> n >> m;
  map<pair<int, int>, int> M;
  v.resize(n + 1);
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d", &x);
    scanf("%d", &y);
    M[make_pair(x, y)] = 1;
    M[make_pair(y, x)] = 1;
    v[x].insert(y);
    v[y].insert(x);
  }
  for (int i = 0; i < n; i++) {
    if (vis[i]) continue;
    vis[i] = 1;
    for (auto it = v[i].begin(); it != v[i].end(); it++) {
      if (check(*it, v[i], i)) {
        vis[*it] = 1;
      } else {
        cout << "NO";
        return 0;
      }
    }
  }
  cout << "YES";
  return 0;
}
