#include <bits/stdc++.h>
using namespace std;
vector<int> a[150002];
bool visited[150002];
long long cnt = 0;
void dfs(int start) {
  cnt++;
  visited[start] = true;
  for (int i = 0; i < a[start].size(); i++) {
    int next = a[start][i];
    if (!visited[next]) {
      dfs(next);
    }
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    a[u].push_back(v);
    a[v].push_back(u);
  }
  long long e = 0;
  for (int i = 1; i <= n; i++) {
    if (!visited[i]) {
      cnt = 0;
      dfs(i);
      e += cnt * (cnt - 1) / 2;
    }
  }
  if (e == m)
    printf("YES");
  else
    printf("NO");
  return 0;
}
