#include <bits/stdc++.h>
using namespace std;
const long long mod = (long long)1e9 + 9;
const int inf = (int)2e9 + 10;
const long long INF = (long long)2e18;
const int base = 1000 * 1000 * 1000;
const int maxn = 200005;
const long double pi = acosl(-1.0);
const long double eps = 1e-9;
vector<vector<int>> g;
long long p = 159871;
void solve() {
  int n, m;
  scanf("%d %d", &n, &m);
  g.resize(n);
  vector<pair<int, int>> e(m);
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    a--, b--;
    g[a].push_back(b);
    g[b].push_back(a);
    e[i] = make_pair(a, b);
  }
  vector<long long> hash(n, 0);
  for (int i = 0; i < n; i++) {
    g[i].push_back(i);
    sort(g[i].begin(), g[i].end());
    for (int j = (int)g[i].size() - 1; j >= 0; j--) {
      hash[i] = hash[i] * p + g[i][j];
    }
  }
  for (int i = 0; i < m; i++) {
    if (hash[e[i].first] != hash[e[i].second]) {
      puts("NO");
      return;
    }
  }
  puts("YES");
}
int main() {
  solve();
  return 0;
}
