#include <bits/stdc++.h>
using namespace std;
int n, m, cnt;
vector<int> a[150004];
int num[150004], sl[150004];
int d[150004];
void DFS(int u) {
  num[u] = cnt;
  for (int i = 0; i < a[u].size(); i++)
    if (num[a[u][i]] == 0) DFS(a[u][i]);
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> m;
  while (m--) {
    int u, v;
    cin >> u >> v;
    d[u]++, d[v]++;
    a[u].push_back(v);
    a[v].push_back(u);
  }
  for (int u = 1; u <= n; u++)
    if (num[u] == 0) {
      cnt++;
      DFS(u);
    }
  for (int i = 1; i <= n; i++) sl[num[i]]++;
  for (int i = 1; i <= n; i++)
    if (d[i] != sl[num[i]] - 1) {
      cout << "NO";
      return 0;
    }
  cout << "YES";
  return 0;
}
