#include <bits/stdc++.h>
using namespace std;
vector<string> tokenizer(string str, char ch) {
  std::istringstream var((str));
  vector<string> v;
  string t;
  while (getline((var), t, (ch))) {
    v.emplace_back(t);
  }
  return v;
}
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cout << *it << " = " << a << "\n";
  err(++it, args...);
}
void file_i_o() {
  freopen("./tests/test01.txt", "r", stdin);
  freopen("./tests/output01.txt", "w", stdout);
}
vector<long long> edges(2 * 100001, 0);
int find(vector<long long>& parent, int a) {
  return parent[a] = (parent[a] == a) ? a : find(parent, parent[a]);
}
void merge(vector<long long>& size, vector<long long>& parent, int a, int b) {
  a = find(parent, parent[a]);
  b = find(parent, parent[b]);
  if (a == b) {
    edges[a]++;
    return;
  }
  if (size[a] > size[b]) {
    parent[b] = a;
    size[a] += size[b];
    edges[a] += edges[b] + 1;
  } else {
    parent[a] = b;
    size[b] += size[a];
    edges[b] += edges[a] + 1;
  }
}
int main(int argc, char const* argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  while (t--) {
    int n;
    cin >> n;
    int m;
    cin >> m;
    vector<long long> sizes(n + 1, 1), parent(n + 1);
    for (int i = 1; i <= n; i++) parent[i] = i;
    while (m--) {
      int a;
      cin >> a;
      int b;
      cin >> b;
      merge(sizes, parent, a, b);
    }
    bool flag = true;
    for (int i = 1; i <= n; i++) {
      if (find(parent, i) == i) {
        if (edges[i] != (sizes[i] * (sizes[i] - 1)) / 2) {
          flag = false;
        }
      }
    }
    if (flag) {
      cout << "YES"
           << "\n";
    } else {
      cout << "NO"
           << "\n";
    }
  }
  return 0;
}
