#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
vector<int> edge[maxn];
bool vis[maxn];
void dfs(int a, long long &vnum, long long &edgenum) {
  vis[a] = true;
  ++vnum;
  edgenum += edge[a].size();
  for (int b : edge[a]) {
    if (!vis[b]) {
      dfs(b, vnum, edgenum);
    }
  }
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      long long a = 0, b = 0;
      dfs(i, a, b);
      if (b != (long long)a * (a - 1)) {
        printf("NO\n");
        return 0;
      }
    }
  }
  printf("YES\n");
  return 0;
}
