#include <bits/stdc++.h>
using namespace std;
vector<int> v[150005], e[150005];
map<pair<int, int>, int> m;
int vis[150005];
long long sum, cnt;
void dfs(int p) {
  vis[p] = 1;
  sum++;
  for (int i = 0; i < v[p].size(); i++) {
    if (!vis[v[p][i]]) dfs(v[p][i]);
    pair<int, int> a;
    a.first = p;
    a.second = v[p][i];
    if (!m[a]) {
      cnt++;
      m[a]++;
      a.first = v[p][i];
      a.second = p;
      m[a]++;
    }
  }
}
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  int x, y;
  memset(vis, 0, sizeof(vis));
  for (int i = 2; i <= n; i++) v[i].clear();
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &x, &y);
    v[x].push_back(y);
    v[y].push_back(x);
  }
  int ok = 1;
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      sum = cnt = 0;
      dfs(i);
      long long ans = (sum * (sum - 1)) / 2;
      if (cnt != ans) {
        ok = 0;
        break;
      }
    }
  }
  if (ok)
    printf("YES\n");
  else
    printf("NO\n");
}
