#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1000000000 + 7;
const long long int MOD1 = 998244353;
const long long int Val9 = 1000000000;
const long long int Val6 = 1000000;
long long int n, m, k;
vector<long long int> vd;
map<long long int, long long int> diff;
long long int no_of_divisors(long long int n) {
  long long int c = 0;
  for (long long int i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      if (n / i == i) {
        c++;
        if (i % 2 != 0) vd.push_back(i);
      } else {
        c += 2;
        if (i % 2 != 0) vd.push_back(i);
        if ((n / i) % 2 != 0) vd.push_back(n / i);
      }
    }
  }
  long long int m = 1000000;
  sort(vd.begin(), vd.end());
  for (long long int i = (long long int)1; i < (long long int)vd.size(); i++) {
    long long int p = vd[i] - vd[i - 1];
    if (p < m) m = p;
  }
  diff[n] = m;
  vd.clear();
  return c;
}
long long int pwr(long long int x, long long int y) {
  long long int r = 1;
  while (y > 0) {
    if (y % 2) r = r * x;
    x *= x;
    y /= 2;
  }
  return r;
}
long long int pwrm(long long int x, long long int y, long long int m) {
  x %= m;
  long long int r = 1;
  while (y > 0) {
    if (y & 1) r = r * x % m;
    x = x * x % m;
    y >>= 1;
  }
  return r;
}
int isPrime(long long int n) {
  if (n <= 1) return 0;
  if (n <= 3) return 1;
  if (n % 2 == 0 || n % 3 == 0) return 0;
  for (long long int i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return 0;
  return 1;
}
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
vector<long long int> vprime;
vector<long long int> vsqr;
void SieveOfEratosthenes(long long int n) {
  bool prime[n + 1];
  memset(prime, true, sizeof(prime));
  for (long long int p = 2; p * p <= n; p++) {
    if (prime[p] == true) {
      for (long long int i = p * p; i <= n; i += p) prime[i] = false;
    }
  }
  for (long long int p = 2; p <= n; p++) {
    if (prime[p]) {
      vprime.push_back(p);
      vsqr.push_back(p * p);
    }
  }
}
bool vis[Val6 + 5] = {false};
long long int ans = -1;
vector<long long int> v[Val6];
vector<long long int> ans1;
long long int dp[Val6] = {0};
long long int countnode[Val6] = {0};
long long int f = 1;
long long int ctr = 0;
long long int dfs(long long int s) {
  long long int m = s;
  ctr++;
  long long int p = v[s].size();
  countnode[s] = 1;
  if (ans1.empty())
    ans1.push_back(v[s].size());
  else {
    if (ans1[0] != v[s].size()) f = 0;
  }
  vis[s] = true;
  long long int c = 0;
  for (long long int i = 0; i < v[s].size(); i++) {
    if (vis[v[s][i]] == false) {
      dfs(v[s][i]);
    }
  }
  return ctr;
}
vector<pair<long long int, pair<long long int, long long int>>> color;
map<long long int, long long int> parent;
long long int bfs(long long int s) {
  queue<long long int> q;
  map<long long int, long long int> level, vtr, sans;
  q.push(s);
  parent[s] = 0;
  level[s] = 1;
  memset(vis, false, sizeof(vis));
  vis[s] = true;
  long long int dist = 0;
  m--;
  vtr[s] = 1;
  while (!q.empty()) {
    long long int p = q.front();
    q.pop();
    for (long long int i = (long long int)0; i < (long long int)v[p].size();
         i++) {
      if (vis[v[p][i]] == false) {
        parent[v[p][i]] = p;
        level[v[p][i]] = level[p] + 1;
        q.push(v[p][i]);
        vis[v[p][i]] = true;
      }
    }
  }
  return dist;
}
long long int nCr(long long int n, long long int r) {
  long long int ans = 1;
  for (long long int i = (long long int)0; i < (long long int)r; i++) {
    ans *= n - i;
    ans /= i + 1;
  }
  return ans;
}
long long int dis[100005];
long long int par[100005];
vector<pair<long long int, long long int>> vp[100005];
long long int dij(long long int n, long long int a, long long int e) {
  for (long long int i = (long long int)0; i < (long long int)n + 1; i++)
    vis[i] = false;
  for (long long int i = (long long int)1; i < (long long int)n + 1; i++) {
    dis[i] = 100000000000000000;
  }
  dis[a] = 0;
  par[a] = 0;
  priority_queue<pair<long long int, long long int>> q;
  q.push({0, a});
  long long int ans = 0;
  long long int c = 0;
  while (!q.empty()) {
    long long int x = q.top().second;
    q.pop();
    if (vis[x]) continue;
    vis[x] = true;
    for (auto it : vp[x]) {
      long long int b = it.first;
      long long int w = it.second;
      if (dis[x] + w < dis[b]) {
        dis[b] = dis[x] + w;
        q.push({-dis[b], b});
        par[b] = x;
      }
    }
  }
  return ans;
}
vector<pair<long long int, pair<long long int, long long int>>> p;
long long int find_set(long long int v) {
  if (v == parent[v]) return v;
  return parent[v] = find_set(parent[v]);
}
long long int kruskal(long long int m) {
  long long int minw = 0;
  for (long long int i = (long long int)0; i < (long long int)m; i++) {
    long long int x = find_set(p[i].second.first);
    long long int y = find_set(p[i].second.second);
    long long int w = p[i].first;
    if (x != y) {
      minw += w;
      parent[y] = x;
    }
  }
  return minw;
}
long long int isvalid(long long int x, long long int y) {
  if (x >= 0 && x < n && y >= 0 && y < m)
    return 1;
  else {
    return 0;
  }
}
long long int visited[1005][1005];
long long int part[1005][1005];
long long int ad[1005][1005];
long long int dx[4] = {-1, 0, 1, 0};
long long int dy[4] = {0, 1, 0, -1};
vector<pair<long long int, long long int>> avp;
long long int ischk(long long int x1, long long int y1) {
  if (x1 == 0 || x1 == n - 1 || y1 == 0 || y1 == m - 1) return 1;
  return 0;
}
bool vis1[1005][1005];
long long int bfsg(long long int x, long long int y, string s[]) {
  queue<pair<long long int, long long int>> q;
  long long int ans = 0;
  q.push({x, y});
  memset(visited, 0, sizeof(visited));
  visited[x][y] = 1;
  long long int f = 0;
  while (!q.empty()) {
    long long int x1 = q.front().first;
    long long int y1 = q.front().second;
    vis1[x1][y1] = true;
    if (x1 == n - 1 && y1 == m - 1) ans = 1;
    q.pop();
    for (long long int i = (long long int)0; i < (long long int)4; i++) {
      if (isvalid(x1 + dx[i], y1 + dy[i]) &&
          visited[x1 + dx[i]][y1 + dy[i]] == 0) {
        long long int newx = x1 + dx[i];
        long long int newy = y1 + dy[i];
        if (s[newx][newy] != '#') {
          visited[newx][newy] = 1;
          part[newx][newy] = part[x][y];
          q.push({newx, newy});
        }
      }
    }
  }
  return ans;
}
long long int findGCD(long long int arr[], long long int n) {
  long long int result = arr[0];
  for (long long int i = 1; i < n; i++) {
    result = gcd(arr[i], result);
    if (result == 1) {
      return 1;
    }
  }
  return result;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  {
    cin >> n >> m;
    for (long long int i = (long long int)0; i < (long long int)m; i++) {
      long long int x, y;
      cin >> x >> y;
      v[x].push_back(y);
      v[y].push_back(x);
    }
    long long int ans = 0;
    for (long long int i = (long long int)1; i < (long long int)n + 1; i++) {
      f = 1;
      ctr = 0;
      if (!vis[i]) {
        if (!v[i].empty()) {
          dfs(i);
          if (ans1[0] != (ctr - 1)) f = 0;
          ans1.clear();
          if (f == 0) ans++;
        }
      }
    }
    if (ans >= 1)
      cout << "NO\n";
    else
      cout << "YES\n";
  }
  cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC
       << "ms\n";
  return 0;
}
