#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > v(150001);
int visit[150001];
vector<int> f;
void dfs(int x) {
  visit[x] = 1;
  f.push_back(x);
  for (int k = 0; k < v[x].size(); k++) {
    if (visit[v[x][k]] == 0) dfs(v[x][k]);
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  set<pair<int, int> > s;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
    s.insert(make_pair(a, b));
    s.insert(make_pair(b, a));
  }
  memset(visit, 0, sizeof(visit));
  ;
  for (int i = 1; i <= n; i++) {
    if (visit[i] == 1) continue;
    f.clear();
    dfs(i);
    for (int j = 0; j < f.size(); j++) {
      for (int k = 0; k < j; k++) {
        int x = f[j];
        int y = f[k];
        if (s.count(make_pair(x, y)) == 0) {
          cout << "NO" << endl;
          return 0;
        }
      }
    }
  }
  cout << "YES";
  return 0;
}
