#include <bits/stdc++.h>
using namespace std;
long long int n, m;
vector<set<long long int> > adj;
vector<bool> vis;
vector<long long int> lev;
void addedge(long long int u, long long int v) {
  adj[u].insert(v);
  adj[v].insert(u);
}
bool bfs(long long int src) {
  queue<long long int> q;
  q.push(src);
  vis[src] = true;
  vector<long long int> v;
  while (!q.empty()) {
    long long int curr = q.front();
    q.pop();
    long long int le = lev[curr];
    v.push_back(curr);
    if (le > 2) {
      return false;
    }
    for (set<long long int>::iterator it = adj[curr].begin();
         it != adj[curr].end(); it++) {
      long long int node = *it;
      if (!vis[node]) {
        q.push(node);
        vis[node] = true;
        lev[node] = le + 1;
      }
    }
  }
  long long int vlen = v.size();
  for (long long int i = 0; i < vlen; i++) {
    for (long long int j = i + 1; j < vlen; j++) {
      if (adj[v[i]].find(v[j]) == adj[v[i]].end()) {
        return false;
      }
    }
  }
  return true;
}
signed main() {
  cin >> n >> m;
  adj.assign(n, set<long long int>());
  lev.assign(n, 1);
  vis.assign(n, false);
  for (long long int i = 0; i < m; i++) {
    long long int u, v;
    cin >> u >> v;
    u--;
    v--;
    addedge(u, v);
  }
  for (long long int i = 0; i < n; i++) {
    if (!vis[i]) {
      if (!bfs(i)) {
        cout << "NO"
             << "\n";
        return 0;
      }
    }
  }
  cout << "YES";
}
