#include <bits/stdc++.h>
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 62;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;
const long double PI = acos(-1);
using namespace std;
int n, m;
vector<vector<int>> g;
void dfs(int cur, vector<int> &cyc, vector<bool> &used, vector<bool> &visited,
         vector<int> &v, bool &ok, int ngf, int ngt) {
  used[cur] = true;
  visited[cur] = true;
  v.push_back(cur);
  for (auto next : g[cur]) {
    if (ngf == cur and ngt == next) continue;
    if (used[next]) {
      cyc.push_back(next);
      for (int i = (int)v.size() - 1; i >= 0; i--) {
        cyc.push_back(v[i]);
        if (v[i] == next) break;
      }
      reverse(cyc.begin(), cyc.end());
      for (int i = 0; i < v.size(); i++) used[i] = false;
      v.clear();
      ok = true;
      return;
    }
    if (visited[next]) continue;
    if (ok) return;
    dfs(next, cyc, used, visited, v, ok, ngf, ngt);
    if (ok) return;
  }
  used[cur] = false;
  v.pop_back();
}
vector<int> find_cycle(int f, int t) {
  vector<int> res, v;
  vector<bool> used(n, false), visited(n, false);
  bool ok = false;
  for (int i = 0; i < n; i++) {
    if (visited[i]) continue;
    dfs(i, res, used, visited, v, ok, f, t);
    if (ok) return res;
  }
  return res;
}
int main() {
  scanf("%d %d", &n, &m);
  g.resize(n);
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    u--;
    v--;
    g[u].emplace_back(v);
  }
  auto cyc = find_cycle(-1, -1);
  if (cyc.empty()) {
    puts("YES");
    return 0;
  } else {
    for (int i = 0; i + 1 < cyc.size(); i++) {
      vector<int> v = find_cycle(cyc[i], cyc[i + 1]);
      if (v.empty()) {
        puts("YES");
        return 0;
      }
    }
  }
  puts("NO");
  return 0;
}
