#include <bits/stdc++.h>
using namespace std;
int n, m, u1, u2, k;
vector<int> v[501];
int d[501];
void dfs(int u) {
  d[u] = 2;
  for (int i = 0; i < v[u].size(); ++i) {
    if (d[v[u][i]] == 2)
      k++;
    else if (!d[v[u][i]])
      dfs(v[u][i]);
  }
  d[u] = 1;
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    cin >> u1 >> u2;
    v[u1].push_back(u2);
  }
  for (int i = 1; i <= n; ++i) {
    memset(d, 0, sizeof d);
    k = 0;
    dfs(i);
    for (int j = 0; j <= n && k <= 1; ++j)
      if (!d[j]) dfs(j);
    if (k <= 1) {
      cout << "YES";
      return 0;
    }
  }
  cout << "NO";
}
