#include <bits/stdc++.h>
using namespace std;
bool visit(long long current, set<long long>& unmarked, vector<int>& mark,
           map<long long, set<long long>>& edges, vector<long long>& cycle) {
  if (mark[current] == 2)
    return true;
  else if (mark[current] == 1)
    return false;
  mark[current] = 1;
  for (const long long& node : edges[current]) {
    if (!visit(node, unmarked, mark, edges, cycle)) {
      cycle.push_back(node);
      return false;
    }
  }
  mark[current] = 2;
  unmarked.erase(current);
  return true;
}
vector<long long> is_acyclic(long long n,
                             map<long long, set<long long>>& edges) {
  set<long long> unmarked;
  vector<int> mark(n + 1, 0);
  for (int i = 1; i < n + 1; ++i) unmarked.insert(i);
  while (!unmarked.empty()) {
    long long node = *unmarked.crbegin();
    vector<long long> cycle;
    if (!visit(node, unmarked, mark, edges, cycle)) {
      reverse(cycle.begin(), cycle.end());
      return cycle;
    }
  }
  return vector<long long>();
}
int main() {
  long long n, m;
  scanf("%lld", &n);
  scanf("%lld", &m);
  map<long long, set<long long>> edges;
  for (int i = 0; i < m; ++i) {
    long long a, b;
    scanf("%lld", &a);
    scanf("%lld", &b);
    edges[a].insert(b);
  }
  vector<long long> cycle = is_acyclic(n, edges);
  if (cycle.empty()) {
    cout << "YES" << endl;
    return 0;
  }
  cycle.push_back(cycle[0]);
  for (int i = 0; i < cycle.size() - 1; ++i) {
    edges[cycle[i]].erase(cycle[i + 1]);
    if (is_acyclic(n, edges).empty()) {
      cout << "YES" << endl;
      return 0;
    }
    edges[cycle[i]].insert(cycle[i + 1]);
  }
  cout << "NO" << endl;
}
