#include <bits/stdc++.h>
using namespace std;
const int N = 505;
const int INF = 1e9 + 7;
int n, m;
vector<int> g[N];
stack<int> verx;
int vis[N], vis2[N];
void remove_edge(int u, int v) {
  for (int i = 0; i < g[u].size(); i++)
    if (g[u][i] == v) {
      g[u].erase(g[u].begin() + i);
      break;
    }
}
void add_edge(int u, int v) { g[u].push_back(v); }
int tvis[N], tvis2[N];
bool dfs2(int u) {
  if (tvis2[u]) {
    return true;
  }
  if (tvis[u]) return false;
  tvis[u] = tvis2[u] = 1;
  bool flag = false;
  for (int v : g[u]) {
    flag |= dfs2(v);
  }
  tvis2[u] = 0;
  return flag;
}
bool cycle() {
  bool flag = false;
  memset(tvis, 0, sizeof(tvis));
  memset(tvis2, 0, sizeof(tvis2));
  for (int i = 0; i < n; i++) {
    if (!tvis[i]) flag |= dfs2(i);
  }
  return flag;
}
void check() {
  assert(!verx.empty());
  int u = verx.top(), v;
  verx.pop();
  bool flag = false;
  while (!verx.empty()) {
    v = u;
    u = verx.top();
    verx.pop();
    remove_edge(u, v);
    flag |= !cycle();
    add_edge(u, v);
  }
  if (flag)
    printf("YES\n");
  else
    printf("NO\n");
  exit(0);
}
void solve(int u) {
  if (vis2[u]) {
    verx.push(u);
    check();
    verx.pop();
    return;
  }
  if (vis[u]) return;
  vis[u] = vis2[u] = 1;
  verx.push(u);
  for (int v : g[u]) {
    solve(v);
  }
  verx.pop();
  vis2[u] = 0;
}
int main() {
  ios_base::sync_with_stdio(false);
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    u--;
    v--;
    g[u].push_back(v);
  }
  for (int i = 0; i < n; i++) {
    if (!vis[i]) solve(i);
  }
  printf("YES\n");
  return 0;
}
