#include <bits/stdc++.h>
int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while ((ch < '0') || (ch > '9')) {
    if (ch == '-') {
      f = -f;
    }
    ch = getchar();
  }
  while ((ch >= '0') && (ch <= '9')) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
const int maxn = 1000000;
const int maxk = 20;
int source[maxk + 3], id[maxn + 3], n, m, cnts, cntt;
int ru[maxn + 10], chu[maxn + 10], to[maxk + 3];
int pre[maxn + 10], now[maxn + 10], son[maxn + 10], tot;
int ins(int a, int b) {
  pre[++tot] = now[a];
  now[a] = tot;
  son[tot] = b;
  return 0;
}
int search(int u, int st) {
  if (id[u]) {
    to[st] |= 1 << (id[u] - 1);
  }
  int j = now[u];
  while (j) {
    int v = son[j];
    search(v, st);
    j = pre[j];
  }
  return 0;
}
int main() {
  n = read();
  m = read();
  for (int i = 1; i <= m; ++i) {
    int a = read(), b = read();
    ins(a, b);
    ++chu[a];
    ++ru[b];
  }
  for (int i = 1; i <= n; ++i) {
    if (!ru[i]) {
      source[++cnts] = i;
    }
    if (!chu[i]) {
      id[i] = ++cntt;
    }
  }
  for (int i = 1; i <= cnts; ++i) {
    search(source[i], i);
  }
  int flag = 0;
  for (int sta = 1; sta < (1 << cnts) - 1; ++sta) {
    int ttot = 0, scnt = 0, cnt = 0;
    for (int i = 1; i <= cnts; ++i) {
      if (sta & (1 << (i - 1))) {
        ++scnt;
        ttot |= to[i];
      }
    }
    for (int i = 1; i <= cnts; ++i) {
      if (ttot & (1 << (i - 1))) {
        ++cnt;
      }
    }
    if (cnt <= scnt) {
      flag = 1;
      break;
    }
  }
  puts(flag ? "NO" : "YES");
  return 0;
}
