#include <bits/stdc++.h>
using namespace std;
vector<int> adj[550];
int last[550];
int state[550], n, m;
bool dfs(int u, vector<pair<int, int> >& edgCycle) {
  state[u] = 1;
  bool ans = 0;
  for (int v : adj[u]) {
    if (state[v] == 1) {
      int ini = v;
      edgCycle.push_back({u, v});
      while (ini != u) {
        v = u;
        u = last[u];
        edgCycle.push_back({u, v});
      }
      return true;
    }
    if (state[v] != 2) {
      last[v] = u;
      ans = ans || dfs(v, edgCycle);
      if (ans) return 1;
    }
  }
  state[u] = 2;
  return ans;
}
bool hasCycle(int u, pair<int, int>& ban) {
  state[u] = 1;
  bool ans = 0;
  for (int v : adj[u]) {
    if (pair<int, int>(u, v) == ban) continue;
    if (state[v] == 1) return true;
    if (state[v] != 2) {
      ans = ans || hasCycle(v, ban);
    }
  }
  state[u] = 2;
  return ans;
}
int main() {
  ;
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    adj[u].push_back(v);
  }
  vector<pair<int, int> > edgCycle;
  for (int i = 0; i < n; i++) {
    if (state[i] == 0) dfs(i, edgCycle);
    if (edgCycle.size()) break;
  }
  if (edgCycle.size()) {
    for (pair<int, int> ban : edgCycle) {
      memset(state, 0, sizeof(state));
      bool ans = 0;
      for (int i = 0; i < n; i++) {
        if (state[i] == 0) ans = ans || hasCycle(i, ban);
      }
      if (!ans) {
        cout << "YES\n";
        return 0;
      }
    }
    cout << "NO\n";
  } else
    cout << "YES\n";
}
