#include <bits/stdc++.h>
using namespace std;
const long long int INF = 9e18L;
const long long int mod = 1e9 + 7;
long long int power(long long int x, long long int y) {
  long long int res = 1;
  int mod = 1e9 + 7;
  while (y > 0) {
    if (y & 1) (res = res * x) %= mod;
    (x = x * x) %= mod;
    y = y >> 1;
  }
  return res % mod;
}
vector<int> adj[150001], vis(150001, 0), v;
int c;
void dfs(int u) {
  vis[u] = 1;
  c++;
  v.push_back(u);
  for (auto x : adj[u]) {
    if (vis[x] == 0) {
      dfs(x);
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  int flag = 1;
  for (int i = 1; i < n + 1 && flag; i++) {
    if (vis[i] == 0) {
      c = 0;
      dfs(i);
      for (auto x : v) {
        if (adj[x].size() != c - 1) {
          flag = 0;
          break;
        }
      }
      v.clear();
    }
  }
  if (flag)
    cout << "YES" << '\n';
  else
    cout << "NO" << '\n';
}
