#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 5;
const long long int inf64 = 1e18 + 5;
const int MAX = 15e4 + 5;
vector<int> v[MAX];
map<int, bool> mp[MAX];
bool vis[MAX];
vector<int> vc;
void dfs(int x) {
  vis[x] = true;
  vc.push_back(x);
  for (auto i : v[x]) {
    if (!vis[i]) dfs(i);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m, i, a, b;
  cin >> n >> m;
  for (i = 0; i < m; i++) {
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
    mp[a][b] = true, mp[b][a] = true;
  }
  for (i = 1; i <= n; i++) {
    if (vis[i]) continue;
    vc.clear();
    dfs(i);
    for (int j = 0; j < vc.size(); j++) {
      for (int k = j + 1; k < vc.size(); k++) {
        if (mp[vc[j]][vc[k]] == 0) {
          cout << "NO";
          return 0;
        }
      }
    }
  }
  cout << "YES\n";
}
