#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x, long long int y) {
  long long int mod = 1e9 + 7;
  long long int ans = 1;
  while (y > 0) {
    if (y & 1) ans = (ans * x) % mod;
    y = y >> 1;
    x = (x * x) % mod;
  }
  return ans;
}
vector<vector<int>> g(501);
int vis[501];
bool cycle(int s, int e1, int e2) {
  if (vis[s] == 1) return 1;
  vis[s] = 1;
  for (auto x : g[s]) {
    if (s == e1 && x == e2) continue;
    if (vis[x] != 2 && cycle(x, e1, e2)) return 1;
  }
  vis[s] = 2;
  return 0;
}
vector<int> cy;
bool h(int s, vector<int>& path) {
  if (vis[s] == 1) {
    cy.push_back(s);
    for (int i = path.size() - 1; i >= 0; i--) {
      cy.push_back(path[i]);
      if (path[i] == s) return 1;
    }
    return 1;
  }
  vis[s] = 1;
  path.push_back(s);
  for (auto x : g[s]) {
    if (vis[x] != 2 && h(x, path)) return 1;
  }
  path.pop_back();
  vis[s] = 2;
  return 0;
}
void solve(int T) {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    g[x].push_back(y);
  }
  vector<int> path;
  cy.clear();
  memset(vis, 0, sizeof(vis));
  for (int i = 1; i <= n; i++) {
    if (vis[i] == 0 && h(i, path)) break;
  }
  if (cy.empty()) {
    cout << "YES";
    return;
  }
  reverse(cy.begin(), cy.end());
  for (int k = 0; k < cy.size() - 1; k++) {
    memset(vis, 0, sizeof(vis));
    bool good = 1;
    for (int i = 1; i <= n; i++) {
      if (vis[i] == 0 && cycle(i, cy[k], cy[k + 1])) {
        good = 0;
        break;
      }
    }
    if (good) {
      cout << "YES";
      return;
    }
  }
  cout << "NO";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  for (int i = 1; i <= t; i++) solve(i);
  return 0;
}
