#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > cmp;
list<int> adj[200200];
bitset<200200> visited;
void dfs(int u) {
  visited[u] = true;
  cmp[((int)(cmp).size()) - 1].push_back(u);
  for (__typeof((adj[u]).begin()) v = (adj[u]).begin(); v != (adj[u]).end();
       v++)
    if (!visited[*v]) dfs(*v);
}
set<pair<int, int> > S;
int main() {
  int n, m, a, b;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < int(m); i++) {
    scanf("%d %d", &a, &b);
    S.insert(make_pair(min(a, b), max(a, b)));
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  for (int i = 1; i <= n; i++)
    if (!visited[i]) {
      cmp.push_back(vector<int>());
      dfs(i);
    }
  for (int i = 0; i < int(((int)(cmp).size())); i++) {
    sort(cmp[i].begin(), cmp[i].end());
    for (int j = 0; j < ((int)(cmp[i]).size()); j++)
      for (int k = 0; k < j; k++)
        if (!S.count(make_pair(min(cmp[i][j], cmp[i][k]),
                               max(cmp[i][j], cmp[i][k])))) {
          printf("NO\n");
          return 0;
        }
  }
  printf("YES\n");
}
