#include <bits/stdc++.h>
using namespace std;
vector<int> comp, g[1000001];
set<pair<int, int> > st;
bool used[10000001];
int n, m;
void dfs(int v) {
  used[v] = true;
  comp.push_back(v);
  for (int i = 0; i < g[v].size(); i++) {
    int to = g[v][i];
    if (!used[to]) {
      dfs(to);
    }
  }
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
    st.insert(make_pair(x, y));
    st.insert(make_pair(y, x));
  }
  for (int i = 1; i <= n; i++) {
    if (used[i]) continue;
    comp.clear();
    dfs(i);
    for (int j = 0; j < comp.size(); j++) {
      for (int k = j + 1; k < comp.size(); k++) {
        if (st.find(make_pair(comp[j], comp[k])) == st.end()) {
          cout << "NO";
          return 0;
        }
      }
    }
  }
  cout << "YES";
  return 0;
}
