#include <bits/stdc++.h>
using namespace std;
bool dfs(vector<set<int> > &adj, int v, vector<char> &color,
         vector<int> &cycle) {
  bool result = true;
  color[v] = 'g';
  for (set<int>::iterator it = adj[v].begin(); it != adj[v].end() && result;
       it++) {
    int nv = *it;
    if (color[nv] == 'w') {
      result = result && dfs(adj, nv, color, cycle);
      if (!result) {
        cycle.push_back(v);
      }
    }
    if (color[nv] == 'g') {
      cycle.push_back(nv);
      cycle.push_back(v);
      result = false;
    }
  }
  color[v] = 'b';
  return result;
}
int main(int argc, const char *argv[]) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<set<int> > adj(n, set<int>());
  vector<pair<int, int> > edges;
  int ef, et;
  for (int i = 0; i < m; i++) {
    cin >> ef >> et;
    ef--, et--;
    adj[ef].insert(et);
    edges.push_back(make_pair(ef, et));
  }
  vector<int> cycle;
  vector<char> color(n, 'w');
  for (int i = 0; i < n; i++) {
    if (color[i] == 'w') {
      dfs(adj, i, color, cycle);
    }
  }
  if (cycle.empty()) {
    cout << "YES" << endl;
  } else {
    int m = cycle.size();
    for (int i = 0; i < m; i++) {
      pair<int, int> e = make_pair(cycle[(i + 1) % m], cycle[i % m]);
      if (adj[e.first].count(e.second) == 1) {
        vector<int> tc;
        adj[e.first].erase(e.second);
        bool possible = true;
        vector<char> color(n, 'w');
        for (int j = 0; j < n; j++) {
          if (color[j] == 'w') {
            possible = possible && dfs(adj, j, color, tc);
          }
        }
        adj[e.first].insert(e.second);
        if (possible) {
          cout << "YES" << endl;
          return 0;
        }
      }
    }
    cout << "NO" << endl;
  }
  return 0;
}
