#include <bits/stdc++.h>
using namespace std;
const int N = 5e2 + 20, M = 1e5 + 20;
int n, m, u[M], v[M], c[N], p[N], e[N];
vector<pair<int, int>> adj[N];
vector<int> vec;
bool found;
void dfs(int node) {
  c[node] = 1;
  for (auto pr : adj[node]) {
    if (found) break;
    int child = pr.first, edge = pr.second;
    if (c[child] == 2) continue;
    if (c[child] == 0) {
      p[child] = node;
      e[child] = edge;
      dfs(child);
    } else {
      found = true;
      for (int i = node; i != child; i = p[i]) vec.push_back(e[i]);
      vec.push_back(edge);
      return;
    }
  }
  c[node] = 2;
}
void check(int node) {
  c[node] = 1;
  for (auto pr : adj[node]) {
    int child = pr.first;
    if (c[child] == 2) continue;
    if (c[child] == 0)
      check(child);
    else
      found = true;
  }
  c[node] = 2;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &u[i], &v[i]);
    adj[u[i]].push_back({v[i], i});
  }
  for (int i = 1; i <= n; i++)
    if (c[i] == 0) dfs(i);
  for (auto edge : vec) {
    for (int i = 1; i <= n; i++) {
      c[i] = 0;
      adj[i].clear();
    }
    for (int i = 0; i < m; i++) {
      if (i == edge) continue;
      adj[u[i]].push_back({v[i], i});
    }
    found = false;
    for (int i = 1; i <= n; i++)
      if (c[i] == 0) check(i);
    if (not found) return 0 * printf("YES");
  }
  printf(vec.empty() ? "YES" : "NO");
}
