#include <bits/stdc++.h>
using namespace std;
const int maxn = 150 * 1000 + 1000;
vector<int> G[maxn], V;
int mark[maxn];
void dfs(int u) {
  mark[u] = 1;
  V.push_back(u);
  for (int i = 0; i < G[u].size(); i++)
    if (!mark[G[u][i]]) dfs(G[u][i]);
  return;
}
int main() {
  int n, m;
  cin >> n >> m;
  while (m--) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  for (int i = 0; i < n; i++) {
    while (V.size()) V.pop_back();
    if (!mark[i]) dfs(i);
    for (int j = 0; j < V.size(); j++)
      if (G[V[j]].size() != V.size() - 1) {
        cout << "NO\n";
        return 0;
      }
  }
  cout << "YES\n";
  return 0;
}
