#include <bits/stdc++.h>
using namespace std;
vector<int> vi[150005];
vector<int>::iterator child;
bool check[150005];
int arr[150005];
queue<int> que;
void dfs(int node) {
  int p = vi[node].size();
  check[node] = true;
  que.push(p);
  for (int child = 0; child < vi[node].size(); child++) {
    if (check[vi[node][child]] == false) {
      dfs(vi[node][child]);
    }
  }
}
int main() {
  int n, m, x, y;
  scanf("%d", &n);
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    scanf("%d", &x);
    scanf("%d", &y);
    vi[x].push_back(y);
    vi[y].push_back(x);
  }
  int res = 0;
  for (int i = 1; i <= n; i++) {
    if (check[i] == false && vi[i].size() != 0) {
      int mm = vi[i].size();
      dfs(i);
      long long int sum = que.size();
      sum = (sum) * (sum - 1);
      long long int c = 0;
      while (!que.empty()) {
        int pp = que.front();
        c += pp;
        que.pop();
      }
      if (c != sum) {
        res++;
        break;
      }
    }
    if (res > 0) break;
  }
  if (res == 0)
    printf("YES");
  else
    printf("NO\n");
}
