#include <bits/stdc++.h>
using namespace std;
const int maxn = 502;
vector<int> adj[maxn];
bool vis[maxn];
bool fin[maxn];
vector<pair<int, int> > edgesInCycle;
int n;
bool dfs(int node) {
  vis[node] = 1;
  for (int ch : adj[node]) {
    edgesInCycle.push_back({node, ch});
    if (!vis[ch]) {
      if (dfs(ch)) return 1;
    } else if (!fin[ch])
      return 1;
    edgesInCycle.pop_back();
  }
  fin[node] = 1;
  return 0;
}
bool checkDag() {
  memset(vis, 0, sizeof(vis));
  memset(fin, 0, sizeof(fin));
  for (int i = 1; i <= n; ++i) {
    if (!vis[i] && dfs(i)) return 0;
  }
  return 1;
}
bool solve() {
  if (checkDag()) return 1;
  vector<pair<int, int> > edges = edgesInCycle;
  for (pair<int, int> edge : edges) {
    int u = edge.first;
    int v = edge.second;
    auto it = find(adj[u].begin(), adj[u].end(), v);
    assert(it != adj[u].end());
    adj[u].erase(it);
    if (checkDag()) return 1;
    adj[u].push_back(v);
  }
  return 0;
}
int main() {
  int m;
  cin >> n >> m;
  int u, v;
  for (int i = 0; i < m; ++i) {
    scanf("%d %d", &u, &v);
    adj[u].push_back(v);
  }
  cout << (solve() ? "YES\n" : "NO\n");
  return 0;
}
