#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
int mod = 1000000007;
class DSU {
 private:
  int numberOfGroups;
  std::vector<int> parents;
  std::vector<int> ranks;

 public:
  DSU(int n) {
    numberOfGroups = n;
    parents = std::vector<int>(n + 1);
    ranks = std::vector<int>(n + 1, 1);
    for (int i = 0; i <= n; i++) {
      parents[i] = i;
    }
  }
  int Find(int index);
  void Union(int index1, int index2);
  bool IsValidIndex(int index);
  void AddGroups();
  int GiveNumberOfGroups();
  int SizeOfGroup(int index);
};
int DSU::Find(int index) {
  if (!IsValidIndex(index)) return -1;
  if (index == parents[index])
    return index;
  else {
    parents[index] = Find(parents[index]);
    return parents[index];
  }
}
void DSU::Union(int index1, int index2) {
  int rindex1 = Find(index1);
  int rindex2 = Find(index2);
  if (rindex1 == rindex2) return;
  if (ranks[rindex1] >= ranks[rindex2]) {
    parents[rindex2] = rindex1;
    ranks[rindex1] += ranks[rindex2];
    numberOfGroups--;
  } else {
    parents[rindex1] = rindex2;
    ranks[rindex2] += ranks[rindex1];
    numberOfGroups--;
  }
}
void DSU::AddGroups() {
  numberOfGroups++;
  int index = (int)parents.size();
  parents.push_back(index);
  ranks.push_back(1);
}
bool DSU::IsValidIndex(int index) {
  if (index >= 1 && index < (int)parents.size()) {
    return true;
  }
  return false;
}
int DSU::SizeOfGroup(int index) {
  if (!IsValidIndex(index)) return -1;
  return ranks[Find(index)];
}
int DSU::GiveNumberOfGroups() { return numberOfGroups; }
struct custom_hash {
  static uint64_t splitmix64(uint64_t x) {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM =
        chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};
int deg[150005];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  int i, j;
  DSU mydsu(n);
  for (i = 0; i <= n; i++) {
    deg[i] = 0;
  }
  for (i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    deg[u]++;
    deg[v]++;
    mydsu.Union(u, v);
  }
  for (i = 1; i <= n; i++) {
    int sz = mydsu.SizeOfGroup(i);
    if (sz != -1) {
      if (deg[i] != sz - 1) {
        cout << "NO"
             << "\n";
        return 0;
      }
    }
  }
  cout << "YES"
       << "\n";
  return 0;
}
