#include <bits/stdc++.h>
using namespace std;
vector<int> p;
vector<int> cor;
int total;
void dfs_visit(vector<vector<int>>& adj, int i) {
  cor[i] = 1;
  for (int j : adj[i]) {
    if (cor[j] == 1) {
      total++;
    }
    if (cor[j] == 0) {
      p[j] = i;
      dfs_visit(adj, j);
    }
  }
  cor[i] = 2;
}
int dfs(vector<vector<int>>& adj, int n) {
  int ans = 10;
  for (int i = 1; i <= n; i++) {
    total = 0;
    p.assign(n + 1, 1);
    cor.assign(n + 1, 0);
    total = 0;
    int j = i;
    if (cor[j] == 0) {
      dfs_visit(adj, j);
    }
    for (int j = 1; j <= n; j++) {
      if (cor[j] == 0) {
        dfs_visit(adj, j);
      }
    }
    ans = min(ans, total);
  }
  return ans;
}
int main() {
  int n, m, a, b;
  cin >> n >> m;
  vector<int> vetor;
  vetor.assign(n + 1, 0);
  vector<vector<int>> adj;
  vector<int> lista;
  lista.clear();
  adj.assign(n + 1, lista);
  for (int i = 1; i <= m; i++) {
    cin >> a >> b;
    adj[a].push_back(b);
  }
  int ans = dfs(adj, n);
  if (ans <= 1)
    cout << "YES\n";
  else
    cout << "NO\n";
  return 0;
}
