#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int MAXV = 1010, MAXE = 100010;
constexpr int MAXN = 1010;
int game[MAXV][MAXV];
int ind[MAXV];
int vlen, elen;
struct E {
  int u, v;
  E() {}
  E(int u, int v) : u(u), v(v) {}
};
int cind[MAXV];
bool check(int S) {
  for (int i = 1; i <= vlen; i++) cind[i] = ind[i];
  cind[S]--;
  cind[S] = max(0, cind[S]);
  queue<int> q;
  for (int i = 1; i <= vlen; i++) {
    if (cind[i] == 0) q.push(i);
  }
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int v = 1; v <= vlen; v++) {
      if (!game[u][v]) continue;
      cind[v]--;
      if (cind[v] == 0) q.push(v);
    }
  }
  for (int i = 1; i <= vlen; i++) {
    if (cind[i] > 0) return false;
  }
  return true;
}
int edx = 0;
int main() {
  ios::sync_with_stdio(false);
  cin >> vlen >> elen;
  for (int i = 0; i < elen; i++) {
    int u, v;
    cin >> u >> v;
    game[u][v] = 1;
    ind[v]++;
  }
  bool ok = false;
  for (int i = 1; i <= vlen; i++) {
    if (check(i)) {
      cout << "YES" << endl;
      ok = true;
      break;
    }
  }
  if (!ok) {
    cout << "NO" << endl;
  }
  return 0;
}
