#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const double eps = 1e-9;
const int maxn = 5e2 + 10;
const int maxm = 1e5 + 10;
int deg[maxn], to[maxm], nex[maxm], beg[maxn], tmp[maxn], q[maxn], tmpv[maxn],
    vis[maxn];
int e;
inline void add(int x, int y) {
  to[++e] = y;
  nex[e] = beg[x];
  beg[x] = e;
}
inline int read() {
  int x = 0, flag = 1;
  char ch = getchar();
  while (!isdigit(ch) && ch != '-') ch = getchar();
  if (ch == '-') flag = -1, ch = getchar();
  while (isdigit(ch)) x = (x << 3) + (x << 1) + ch - '0', ch = getchar();
  return x * flag;
}
int main() {
  int i, j, k, m, n;
  n = read();
  m = read();
  for (i = 1; i <= m; i++) {
    int x, y;
    x = read();
    y = read();
    add(x, y);
    deg[y]++;
  }
  int f, l, cnt = 0;
  f = l = 0;
  for (i = 1; i <= n; i++) {
    if (!deg[i]) q[++l] = i, cnt++;
  }
  while (f < l) {
    int x = q[++f];
    for (i = beg[x]; i; i = nex[i])
      if (!vis[to[i]] && !(--deg[to[i]])) q[++l] = to[i], cnt++, vis[to[i]] = 1;
  }
  if (cnt == n) return puts("YES"), 0;
  int sum = 0;
  for (i = 1; i <= n; i++) {
    if (deg[i] == 1) {
      sum = cnt;
      for (j = 1; j <= n; j++) tmp[j] = deg[j], tmpv[j] = vis[j];
      f = l = 0;
      q[++l] = i;
      tmpv[i] = 1;
      sum++;
      while (f < l) {
        int x = q[++f];
        for (j = beg[x]; j; j = nex[j]) {
          if (!tmpv[to[j]] && !(--tmp[to[j]])) {
            q[++l] = to[j];
            tmpv[to[j]] = 1;
            sum++;
          }
        }
      }
    }
    if (sum == n) return puts("YES"), 0;
  }
  puts("NO");
  return 0;
}
