#include <bits/stdc++.h>
using namespace std;
vector<int> g[100005];
int vis[100005];
int cnt;
int n, m;
void dfs(int src) {
  vis[src] = 1;
  for (int u : g[src]) {
    if (vis[u] == 0)
      dfs(u);
    else if (vis[u] == 1)
      cnt++;
  }
  vis[src] = 2;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    g[a].push_back(b);
  }
  bool flag = false;
  for (int i = 1; i <= n; i++) {
    memset(vis, 0, sizeof vis);
    cnt = 0;
    dfs(i);
    for (int j = 1; j <= n; j++)
      if (!vis[j]) dfs(j);
    if (cnt < 2) {
      flag = true;
    }
  }
  if (!flag)
    cout << "NO";
  else
    cout << "YES";
  cout << "\n";
}
