#include <bits/stdc++.h>
using namespace std;
long long int exp(long long int t, long long int x) {
  if (x == 0) return 1;
  if (x == 1) return t;
  if (x % 2 == 1) return (t * exp((t * t) % 1000000007, x / 2)) % 1000000007;
  if (x % 2 == 0) return exp((t * t) % 1000000007, x / 2);
}
long long int gcd(long long int x, long long int y) {
  return x % y == 0 ? y : gcd(y, x % y);
}
long long int lcm(long long int x, long long int y) {
  return x * (y / gcd(x, y));
}
bool isprime(long long int x) {
  for (long long int i = 2; i * i <= x; i++) {
    if (x % i == 0) {
      return false;
    }
  }
  return true;
}
vector<int> edges[160000];
bool visited[160000];
bool dfs(int node, int num, int &counter) {
  visited[node] = true;
  int n = edges[node].size();
  int neigh;
  for (int(i) = (0); (i) <= (n - 1); (i)++) {
    neigh = edges[node][i];
    if (visited[neigh]) continue;
    if (edges[neigh].size() != num) return false;
    dfs(neigh, num, counter);
  }
  counter += 1;
  return true;
}
int main() {
  int n, m;
  int x, y;
  scanf("%d %d", &n, &m);
  for (int(i) = (1); (i) <= (m); (i)++) {
    scanf("%d %d", &x, &y);
    edges[x].push_back(y);
    edges[y].push_back(x);
  }
  memset(visited, 0, sizeof visited);
  int counter;
  bool res = true;
  for (int(i) = (1); (i) <= (n); (i)++) {
    if (visited[i]) continue;
    counter = 0;
    bool check = dfs(i, edges[i].size(), counter);
    if (!check || counter != edges[i].size() + 1) {
      res = false;
      break;
    }
  }
  if (res)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
