#include <bits/stdc++.h>
using namespace std;
namespace StandardIO {
template <typename T>
inline void read(T &x) {
  x = 0;
  T f = 1;
  char c = getchar();
  for (; c < '0' || c > '9'; c = getchar())
    if (c == '-') f = -1;
  for (; c >= '0' && c <= '9'; c = getchar()) x = x * 10 + c - '0';
  x *= f;
}
template <typename T>
inline void write(T x) {
  if (x < 0) putchar('-'), x *= -1;
  if (x >= 10) write(x / 10);
  putchar(x % 10 + '0');
}
}  // namespace StandardIO
using namespace StandardIO;
namespace Solve {
const int N = 505;
int n, m;
vector<int> graph[N];
int indeg[N];
queue<int> q;
inline bool toposort(int n) {
  int temp[N], size = 0;
  memcpy(temp, indeg, sizeof(indeg));
  while (!q.empty()) q.pop();
  for (register int i = 1; i <= n; ++i) {
    if (temp[i] == 0) q.push(i), size++;
  }
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    for (register int i = 0; i < graph[v].size(); ++i) {
      int to = graph[v][i];
      temp[to]--;
      if (temp[to] == 0) q.push(to), size++;
    }
  }
  return size >= n;
}
inline void solve() {
  read(n), read(m);
  for (register int i = 1; i <= m; ++i) {
    int x, y;
    read(x), read(y);
    indeg[y]++;
    graph[x].push_back(y);
  }
  for (register int i = 1; i <= n; ++i) {
    if (indeg[i] != 0) {
      indeg[i]--;
      if (toposort(n)) {
        puts("YES");
        return;
      }
      indeg[i]++;
    }
  }
  puts("NO");
}
}  // namespace Solve
using namespace Solve;
int main() { solve(); }
