#include <bits/stdc++.h>
const int MAXM = 100000 + 10, MAXN = 500 + 10;
struct Edge {
  int v, next;
} edge[MAXM];
int head[MAXN], tail, deg[MAXN], n, m;
void insert(int u, int v) {
  edge[++tail] = (Edge){v, head[u]};
  head[u] = tail;
  deg[v]++;
}
namespace solver1 {
int half[MAXN];
bool check(int x) {
  memcpy(deg, half, sizeof half);
  deg[x]--;
  std::queue<int> q;
  q.push(x);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = head[u]; i; i = edge[i].next) {
      int v = edge[i].v;
      if (v == x) continue;
      if (!(--deg[v])) q.push(v);
    }
  }
  for (int i = 1; i <= n; i++) {
    if (deg[i]) return 0;
  }
  return 1;
}
void main() {
  std::queue<int> q;
  for (int i = 1; i <= n; i++) {
    if (!deg[i]) q.push(i);
  }
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = head[u]; i; i = edge[i].next) {
      int v = edge[i].v;
      if (!(--deg[v])) q.push(v);
    }
  }
  bool ok = 1;
  for (int i = 1; i <= n; i++) {
    if (deg[i]) ok = 0;
  }
  if (ok) {
    puts("YES");
    return;
  }
  memcpy(half, deg, sizeof deg);
  for (int i = 1; i <= n; i++) {
    if (half[i] == 1 && check(i)) {
      puts("YES");
      return;
    }
  }
  puts("NO");
}
}  // namespace solver1
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    insert(u, v);
  }
  solver1::main();
}
