#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 5;
const long long INF = 1e18;
const long long mod = 1e9 + 7;
const double pi = 2 * acos(0);
vector<vector<int> > vec(N);
long long c, cnt;
bool vis[N];
void dfs(int node) {
  vis[node] = true;
  c++;
  cnt += vec[node].size();
  for (auto i : vec[node])
    if (!vis[i]) dfs(i);
}
int main() {
  long long n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    vec[a].push_back(b);
    vec[b].push_back(a);
  }
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      c = cnt = 0;
      dfs(i);
      if (((c - 1) * c) != cnt) return cout << "NO", 0;
    }
  }
  cout << "YES";
  return 0;
}
