#include <bits/stdc++.h>
using namespace std;
ifstream in("file.in");
ofstream out("file.out");
struct comp {
  bool operator()(int a, int b) { return a > b; }
};
int n, m, first, second, z, v[150005], cnt;
vector<int> g[150005], p;
void DFS(int nod) {
  if (v[nod]) return;
  v[nod] = 1;
  cnt++;
  p.push_back(nod);
  for (int i : g[nod]) DFS(i);
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> first >> second;
    g[first].push_back(second);
    g[second].push_back(first);
  }
  for (int i = 1; i <= n; i++) {
    if (!v[i]) {
      cnt = 0;
      p.clear();
      DFS(i);
      for (int j : p) {
        if (g[j].size() < cnt - 1) {
          cout << "NO";
          return 0;
        }
      }
    }
  }
  cout << "YES";
}
