#include <bits/stdc++.h>
using namespace std;
const int maxn = 150 * 1000 + 10;
int n, m, deg[maxn], col[maxn], sz[maxn], cmp;
bool mark[maxn];
vector<int> g[maxn];
int dfs(int x, int c) {
  int ret = 1;
  mark[x]++;
  col[x] = c;
  for (auto child : g[x])
    if (!mark[child]) ret += dfs(child, c);
  return ret;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  for (int i = 0, x, y; i < m; i++) {
    cin >> x >> y, x--, y--;
    g[x].push_back(y), g[y].push_back(x);
    deg[x]++, deg[y]++;
  }
  for (int i = 0; i < n; i++)
    if (!mark[i]) sz[cmp] = dfs(i, cmp++);
  for (int i = 0; i < n; i++)
    if (deg[i] != sz[col[i]] - 1) return cout << "NO" << endl, 0;
  cout << "YES" << endl;
}
