#include <bits/stdc++.h>
using namespace std;
const int N = 5e2 + 10;
int n, m;
bool G[N][N];
namespace Check {
int d[N];
queue<int> Q;
void init() {
  memset(d, 0, sizeof(d));
  for (int u = 1; u <= n; ++u)
    for (int v = 1; v <= n; ++v)
      if (G[u][v]) ++d[v];
}
bool check() {
  init();
  for (int i = 1; i <= n; ++i)
    if (d[i] == 0) Q.push(i);
  int cnt = 0;
  while (!Q.empty()) {
    int u = Q.front();
    Q.pop();
    ++cnt;
    for (int v = 1; v <= n; ++v) {
      if (!G[u][v]) continue;
      --d[v];
      if (d[v] == 0) Q.push(v);
    }
  }
  return cnt == n;
}
}  // namespace Check
using Check::check;
namespace Solve {
int fa[N];
bool vis[N], inC[N];
inline void quit(const char *s) {
  puts(s);
  exit(0);
}
void dfs(int u, int f) {
  vis[u] = inC[u] = true;
  fa[u] = f;
  for (int v = 1; v <= n; ++v) {
    if (!G[u][v]) continue;
    if (!vis[v]) {
      dfs(v, u);
    } else if (inC[v]) {
      G[u][v] = false;
      if (check()) quit("YES");
      G[u][v] = true;
      for (int i = u; i != v; i = fa[i]) {
        G[fa[i]][i] = false;
        if (check()) quit("YES");
        G[fa[i]][i] = true;
      }
      quit("NO");
    }
  }
  inC[u] = false;
}
void solve() {
  for (int i = 1; i <= n; ++i)
    if (!vis[i]) dfs(i, 0);
  puts("YES");
}
}  // namespace Solve
using Solve::solve;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    G[u][v] = true;
  }
  solve();
  return 0;
}
