#include <bits/stdc++.h>

using namespace std;

const int N = 1e6;
  
void timeS( const char *s = 0 ) { fprintf(stderr, "time = %.2f : %s\n", 1. * clock() / CLOCKS_PER_SEC, s ? s : ""); }

template <class T = int> inline T readInt(); 

#define forn(i, n) for (int i = 0; i < (int)(n); i++)

void solve() {
  int cc = 0, n, m;
  n = readInt();
  m = readInt();
  vector<int> colors(n, 0);

  /** Мультисписок  */
  struct MultiList {
    int e = 0, next[2 * m], to[2 * m];
    vector<int> head(n, -1);

    void add( int a, int b ) {
      next[e] = head[a], to[e] = b, head[a] = e++;
    }
  } o;
  /** Мультисписок  */

  // vector<int> c[n];
  function<void(int,int)> dfs = [&]( int v, int color ) {
    if (colors[v]) return;
    colors[v] = color;
    for (int e = head[v]; e != -1; e = next[e])
      dfs(to[e], 3 - color);
  };
  // list<int> c[n]
  forn(i, m) {
    int a = readInt() - 1;
    int b = readInt() - 1;
    add(a, b);
    add(b, a);
  }
  timeS("read and build");
  for (int i = 0; i < n; i++)
    if (!colors[i])
      cc++, dfs(i, 2);
  timeS("dfs");
  puts(cc == 1 ? "YES" : "NO");
}

/** Read */

static const int buf_size = 4096;

inline int getChar() {
  static char buf[buf_size];
  static int len = 0, pos = 0;
  if (pos == len)
    pos = 0, len = fread(buf, 1, buf_size, stdin);
  if (pos == len)
    return -1;
  return buf[pos++];
}

inline int readChar() {
  int c = getChar();
  while (c <= 32)
    c = getChar();
  return c;
}

template <class T>
inline T readInt() {
  int s = 1, c = readChar();
  T x = 0;
  if (c == '-')
    s = -1, c = getChar();
  while ('0' <= c && c <= '9')
    x = x * 10 + c - '0', c = getChar();
  return s == 1 ? x : -x;
}

int main() {
  solve();
  timeS("end");
}