#include <bits/stdc++.h>
using namespace std;
int *a;
int n;
vector<pair<int, int>> ve;
bool find(int i, int j) {
  for (int k = 0; k < ve.size(); k++) {
    if (ve[k].first == i && ve[k].second == j ||
        (ve[k].first == j && ve[k].second == i))
      return true;
  }
  return false;
}
int c = -1;
int *visited;
vector<int> vec;
class Graph {
  int V;
  list<int> *adj;
  void DFSUtil(int v);

 public:
  Graph(int V);
  void addEdge(int v, int w);
  bool isReachable(int s, int d);
  void DFS(int v);
};
Graph::Graph(int V) {
  this->V = V;
  adj = new list<int>[V];
}
void Graph::addEdge(int v, int w) { adj[v].push_back(w); }
void Graph::DFSUtil(int v) {
  visited[v] = 1;
  vec.push_back(adj[v].size());
  list<int>::iterator i;
  for (i = adj[v].begin(); i != adj[v].end(); ++i) {
    if (visited[*i] == 0) {
      DFSUtil(*i);
    }
  }
}
void Graph::DFS(int v) { DFSUtil(v); }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  Graph g(n + 1);
  int m, x, y;
  cin >> m;
  a = new int[n + 1];
  memset(a, 0, n + 1);
  while (m--) {
    cin >> x >> y;
    a[x]++;
    a[y]++;
    g.addEdge(x, y);
    g.addEdge(y, x);
    ve.push_back({x, y});
  }
  visited = new int[n + 1];
  for (int i = 0; i < n + 1; i++) visited[i] = 0;
  for (int i = 1; i < n + 1; i++) {
    if (a[i] == 0) {
      continue;
    }
    if (visited[i] == 0) {
      g.DFS(i);
    } else
      continue;
    sort(vec.begin(), vec.end());
    if (vec[0] != vec[vec.size() - 1] || vec[0] != vec.size() - 1)
      return cout << "NO", 0;
    vec.clear();
  }
  cout << "YES";
  return 0;
}
