#include <bits/stdc++.h>
using namespace std;
vector<int> ed[150005];
int n, m, a, b, boya, mark[150005], s1[150005], s2[150005];
void dfs(int x, int b) {
  if (mark[x]) return;
  mark[x] = b;
  s2[b]++;
  for (int i = 0; i < (int)ed[x].size(); i++) dfs(ed[x][i], boya);
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d %d", &a, &b);
    s1[a]++;
    s1[b]++;
    ed[a].push_back(b);
    ed[b].push_back(a);
  }
  for (int i = 1; i <= n; i++) {
    if (mark[i] == 0) dfs(i, ++boya);
  }
  for (int i = 1; i <= n; i++)
    if (s2[mark[i]] != s1[i] + 1) {
      printf("NO");
      return 0;
    };
  printf("YES");
}
