#include <bits/stdc++.h>
#pragma GCC optimize("O3")
const double PI = acos(-1);
using namespace std;
const int MAXV = 500 + 10, MAXE = 100 * 1000 + 10;
vector<int> E[MAXE], ST;
int fr[MAXE], to[MAXE], weight[MAXE];
int dfs_in[MAXV], dfs_low[MAXV], dfs_time;
bool inStack[MAXV];
int SCC_id[MAXV], SCC_cnt, n;
vector<int> SCC[MAXV], SCC_adj[MAXV];
int vis[MAXV];
bool adj[MAXV][MAXV];
void tarjanSCC(int u) {
  dfs_in[u] = dfs_low[u] = dfs_time++;
  ST.push_back(u);
  inStack[u] = true;
  for (int e : E[u]) {
    int v = to[e];
    if (dfs_in[v] == -1) {
      tarjanSCC(v);
      dfs_low[u] = min(dfs_low[u], dfs_low[v]);
    } else if (inStack[v]) {
      dfs_low[u] = min(dfs_low[u], dfs_low[v]);
    }
  }
  if (dfs_low[u] == dfs_in[u]) {
    bool done = 0;
    while (!done) {
      int v = ST.back();
      SCC_id[v] = SCC_cnt;
      SCC[SCC_id[v]].push_back(v);
      ST.pop_back();
      done = v == u;
      inStack[v] = 0;
    }
    SCC_cnt++;
  }
}
int dfs(int u, int id, int f, int t) {
  if (vis[u] == 1) return 1;
  if (vis[u] == 2) return 0;
  vis[u] = 1;
  int ret = 0;
  for (int e : E[u]) {
    int v = to[e];
    if (SCC_id[v] != id) continue;
    if (f == u && t == v) continue;
    ret += dfs(v, id, f, t);
  }
  vis[u] = 2;
  return ret;
}
int main() {
  int m;
  scanf("%d %d", &n, &m);
  for (int e = 0; e < (m); e++) {
    scanf("%d %d", fr + e, to + e);
    E[fr[e]].push_back(e);
    adj[fr[e]][to[e]] = 1;
  }
  fill(dfs_in, dfs_in + n + 1, -1);
  for (int i = (1); i <= (n); i++)
    if (dfs_in[i] == -1) tarjanSCC(i);
  vector<int> C1;
  for (int i = 0; i < (SCC_cnt); i++)
    if (((int)SCC[i].size()) > 1) C1.push_back(i);
  if (((int)C1.size()) > 1) return puts("NO"), 0;
  if (((int)C1.size()) == 0) return puts("YES"), 0;
  int id = C1[0];
  vector<int> indeg(n + 1, 0), I(n + 1, 0);
  for (int u : SCC[id])
    for (int e : E[u]) {
      int v = to[e];
      if (SCC_id[v] != id) continue;
      indeg[v]++;
      I[v] = u;
    }
  for (int v : SCC[id]) {
    memset(vis, 0, sizeof vis);
    if (!dfs(v, id, I[v], v)) return puts("YES"), 0;
  }
  puts("NO");
  return 0;
}
