#include <bits/stdc++.h>
using namespace std;
int n, m, d[510], a[510];
vector<int> g[510];
bool topsort(int x) {
  memcpy(a, d, sizeof(d));
  int num = 0;
  a[x]--;
  queue<int> q;
  for (int i = 1; i <= n; i++)
    if (a[i] == 0) q.push(i), num++;
  while (!q.empty()) {
    int i = q.front();
    q.pop();
    for (int j = 0; j < g[i].size(); j++)
      if (!(--a[g[i][j]])) q.push(g[i][j]), num++;
  }
  return num == n;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    g[u].push_back(v);
    d[v]++;
  }
  for (int i = 1; i <= n; i++)
    if (topsort(i)) {
      puts("YES");
      return 0;
    }
  puts("NO");
  return 0;
}
