#include <bits/stdc++.h>
using namespace std;
long long n, m, a, b;
vector<int> grafo[505], cyc;
int vis[505], cycle;
bool ok;
void find(int nodo) {
  vis[nodo]++;
  for (int i = 0; i < grafo[nodo].size() && ok; i++) {
    if ((nodo != a || grafo[nodo][i] != b) && vis[grafo[nodo][i]] < 2) {
      if (vis[grafo[nodo][i]] == 1) {
        ok = false;
        break;
      } else
        find(grafo[nodo][i]);
    }
  }
  vis[nodo]++;
}
void dfs(int nodo) {
  if (vis[nodo] == 1) {
    cycle = 1;
    vis[nodo]++;
    cyc.push_back(nodo);
    return;
  }
  vis[nodo]++;
  for (int i = 0; i < grafo[nodo].size(); i++) {
    if (vis[grafo[nodo][i]] != 2) dfs(grafo[nodo][i]);
    if (cycle > 0) break;
  }
  if (vis[nodo] == 2) {
    cycle = 2;
    cyc.push_back(nodo);
    return;
  }
  if (vis[nodo] == 1 && cycle == 1) cyc.push_back(nodo);
  vis[nodo]++;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    grafo[a].push_back(b);
  }
  for (int i = 1; i <= n; i++) {
    if (cycle == 0)
      dfs(i);
    else
      break;
  }
  ok = true;
  for (int i = 0; i < int(cyc.size()) - 1; i++) {
    ok = true;
    a = cyc[i + 1];
    b = cyc[i];
    for (int j = 0; j <= n; j++) vis[j] = 0;
    for (int j = 1; j <= n; j++)
      if (vis[j] == 0) find(j);
    if (ok == true) {
      break;
    }
  }
  if (ok)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
