#include <bits/stdc++.h>
using namespace std;
inline int read(int f = 1, int x = 0, char ch = ' ') {
  while (!isdigit(ch = getchar()))
    if (ch == '-') f = -1;
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  return f * x;
}
const int N = 5e2 + 5, M = 1e5 + 5;
int n, m, h[N], nxt[M], to[M], in[N], old[N], tot;
bool chk(int p) {
  memcpy(old + 1, in + 1, sizeof(int) * n), --in[p];
  static int q[N], l, r;
  l = 1, r = 0;
  for (int i = 1; i <= n; ++i)
    if (!in[i]) q[++r] = i;
  while (l <= r)
    for (int x = q[l++], i = h[x]; i; i = nxt[i])
      if (!--in[to[i]]) q[++r] = to[i];
  if (r != n) memcpy(in + 1, old + 1, sizeof(int) * n);
  return r == n;
}
int main() {
  n = read(), m = read();
  for (int i = 1, x, y; i <= m; ++i)
    x = read(), y = read(), nxt[++tot] = h[x], to[tot] = y, h[x] = tot, ++in[y];
  for (int i = 1; i <= n; ++i)
    if (in[i] && chk(i)) return puts("YES"), 0;
  puts("NO");
  return 0;
}
