#include <bits/stdc++.h>
using namespace std;
vector<int> v[200005], vv[200005];
bool vis[200005];
int pa = 0, n, m, a, b;
void dfs(int x) {
  vis[x] = true;
  vv[pa].push_back(x);
  for (int i = 0; i < v[x].size(); i++) {
    if (vis[v[x][i]] == false) dfs(v[x][i]);
  }
}
int main() {
  int i, ok, j, noo = 0;
  cin >> n >> m;
  for (i = 0; i < m; i++) {
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  for (i = 1; i <= n; i++) {
    if (vis[i] == false && v[i].size() > 0) {
      dfs(i);
      pa++;
    }
  }
  for (i = 0; i < pa; i++) {
    ok = vv[i].size();
    ok--;
    for (j = 0; j <= ok; j++) {
      if (v[vv[i][j]].size() != ok) {
        noo = 1;
        break;
      }
    }
  }
  if (noo)
    cout << "NO";
  else
    cout << "YES";
}
