#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > g;
int n;
vector<bool> b;
vector<int> v;
stack<int> st;
bool fi;
vector<bool> dins;
void dfs(int u) {
  if (fi) return;
  if (b[u]) {
    if (dins[u]) {
      fi = true;
      v.push_back(u);
      while (!st.empty() and st.top() != u) {
        v.push_back(st.top());
        st.pop();
      }
      v.push_back(u);
    } else
      return;
  }
  b[u] = true;
  st.push(u);
  dins[u] = true;
  for (int i = 0; i < g[u].size(); ++i) {
    dfs(g[u][i]);
  }
  if (fi) return;
  st.pop();
  dins[u] = false;
}
bool check(int x, int y, vector<int> d) {
  --d[y];
  queue<int> q;
  for (int i = 0; i < n; ++i) {
    if (d[i] == 0) q.push(i);
  }
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = 0; i < g[u].size(); ++i) {
      if (u != x or g[u][i] != y) {
        --d[g[u][i]];
        if (d[g[u][i]] == 0) q.push(g[u][i]);
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    if (d[i]) {
      return false;
    }
  }
  return true;
}
int main() {
  int m;
  cin >> n >> m;
  g = vector<vector<int> >(n);
  vector<int> d(n, 0);
  for (int i = 0; i < m; ++i) {
    int x, y;
    cin >> x >> y;
    --x;
    --y;
    ++d[y];
    g[x].push_back(y);
  }
  b = vector<bool>(n, false);
  dins = vector<bool>(n, false);
  fi = false;
  for (int i = 0; i < n; ++i) {
    if (!b[i] and !fi) dfs(i);
  }
  for (int i = 1; i < v.size(); ++i) {
    if (check(v[i], v[i - 1], d)) {
      cout << "YES" << endl;
      return 0;
    }
  }
  if (v.empty())
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
