#include <bits/stdc++.h>
using namespace std;
const int N = 1e7;
vector<vector<int>> adj;
int n, m, a, b;
int vis[510];
int ans;
void dfs(int node) {
  vis[node] = 2;
  for (auto x : adj[node]) {
    if (!vis[x])
      dfs(x);
    else if (vis[x] == 2)
      ++ans;
  }
  vis[node] = 1;
}
int main() {
  scanf("%d%d", &n, &m);
  adj.resize(n + 1);
  for (int i = 0; i < m; ++i) {
    scanf("%d%d", &a, &b);
    adj[a].push_back(b);
  }
  for (int i = 1; i <= n; ++i) {
    memset(vis, 0, sizeof(vis));
    ans = 0;
    dfs(i);
    for (int j = 0; j <= n && ans <= 1; ++j)
      if (!vis[j]) dfs(j);
    if (ans <= 1) {
      cout << "YES";
      return 0;
    }
  }
  cout << "NO";
  return 0;
}
