#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 << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;
using namespace std;
vector<vector<int>> g;
vector<bool> used;
vector<bool> visited;
void dfs(int cur, int ng1, int ng2, vector<int>& v, vector<int>& res) {
  if (res.size()) return;
  v.push_back(cur);
  used[cur] = true;
  visited[cur] = true;
  for (auto next : g[cur]) {
    if (cur == ng1 and next == ng2) continue;
    if (res.size()) return;
    if (used[next]) {
      for (int i = 0; i < v.size(); i++) {
        if (v[i] == next) {
          for (int j = i; j < v.size(); j++) res.push_back(v[j]);
          res.push_back(next);
          break;
        }
      }
      used[cur] = false;
      v.pop_back();
      return;
    } else if (!visited[next]) {
      dfs(next, ng1, ng2, v, res);
    }
  }
  used[cur] = false;
  v.pop_back();
}
vector<int> find_cycle(int ng1, int ng2) {
  int n = g.size();
  visited = vector<bool>(n, false);
  used = vector<bool>(n, false);
  vector<int> v, res;
  for (int i = 0; i < n; i++) {
    if (visited[i]) continue;
    dfs(i, ng1, ng2, v, res);
    if (res.size() > 0) return res;
  }
  return res;
}
int main() {
  int n, m;
  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].push_back(v);
  }
  auto cyc = find_cycle(-1, -1);
  if (cyc.empty()) {
    puts("YES");
    return 0;
  }
  for (int i = 0; i + 1 < cyc.size(); i++) {
    auto res = find_cycle(cyc[i], cyc[i + 1]);
    if (res.empty()) {
      puts("YES");
      return 0;
    }
  }
  puts("NO");
  return 0;
}
