#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long N = 2e5 + 7;
long long n, ans = 1e9, x, tmp, m;
vector<long long> v[N];
map<int, int> vis;
void dfs(long long node, long long &edges, long long &vertex) {
  vis[node]++;
  edges += v[node].size();
  ++vertex;
  for (int i = 0; i < v[node].size(); i++)
    if (!vis[v[node][i]]) dfs(v[node][i], edges, vertex);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  for (int i = 1; i <= n; i++)
    if (!vis[i]) {
      long long edges = 0, vertex = 0;
      dfs(i, edges, vertex);
      if (edges != vertex * (vertex - 1)) return cout << "NO\n", 0;
    }
  cout << "YES\n";
  return 0;
}
