#include <bits/stdc++.h>
using namespace std;
vector<long long> adj[151234];
bool vis[151234];
vector<long long> temp;
long long ct;
void dfs(long long a) {
  vis[a] = true;
  for (int i = 0; i < adj[a].size(); i++) {
    long long b = adj[a][i];
    if (vis[b] == false) {
      ct++;
      temp.push_back(b);
      dfs(b);
    }
  }
}
int main() {
  long long n, m, u, v;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) vis[i] = false;
  for (int i = 1; i <= m; i++) {
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  bool flag = true;
  for (int i = 1; i <= n; i++) {
    if (vis[i] == false) {
      ct = 1;
      temp.clear();
      temp.push_back(i);
      dfs(i);
      for (int j = 0; j < temp.size(); j++) {
        if (adj[temp[j]].size() != ct - 1) flag = false;
      }
    }
  }
  if (flag == true)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
