#include <bits/stdc++.h>
using namespace std;
const int inf = 2009000999;
const long long infll = 1e18;
const double eps = 1e-3;
const int maxn = 2e5 + 55;
const int maxk = 55;
const int base = 1073741789;
const long long basell = 1e18 + 3;
const long double PI = acos(-1.0);
string itosm(long long x) {
  string ans = "";
  while (x > 0) {
    ans += ((x % 10) + '0');
    x /= 10;
  }
  reverse(ans.begin(), ans.end());
  return ans;
}
long long stoim(string str) {
  long long ans = 0;
  long long k = 1;
  for (int i = str.length() - 1; i >= 0; i--) {
    ans += (str[i] - '0') * k;
    k *= 10;
  }
  return ans;
}
pair<int, int> a[maxn];
vector<int> g[maxn];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> a[i].first >> a[i].second;
    g[a[i].first].push_back(a[i].second);
    g[a[i].second].push_back(a[i].first);
  }
  for (int i = 0; i <= n; i++) sort(g[i].begin(), g[i].end());
  for (int i = 0; i < m; i++) {
    if (g[a[i].first].size() != g[a[i].second].size()) {
      cout << "NO";
      return 0;
    } else {
      int j1 = 0, j2 = 0;
      while (j1 < g[a[i].first].size() && j2 < g[a[i].first].size()) {
        if (g[a[i].first][j1] != g[a[i].second][j2]) {
          if (g[a[i].first][j1] == a[i].second) j1++;
          if (g[a[i].second][j2] == a[i].first) j2++;
          if (g[a[i].first][j1] != g[a[i].second][j2] &&
              j1 < g[a[i].first].size() && j2 < g[a[i].first].size()) {
            cout << "NO";
            return 0;
          }
        }
        j1++;
        j2++;
      }
    }
  }
  cout << "YES";
  return 0;
}
