#include <bits/stdc++.h>
using namespace std;
const int Nmax = 505;
int n, m, edgeNum, pEdge[Nmax], path[100005], pathNum, banId[100005], banNum;
struct Edge {
  int t1, t2, next, pre;
};
Edge edge[100005];
void addEdge(int t1, int t2) {
  Edge &now = edge[edgeNum];
  now.t1 = t1;
  now.t2 = t2;
  int next = pEdge[t1];
  if (next) edge[next].pre = edgeNum;
  now.next = next;
  now.pre = 0;
  pEdge[t1] = edgeNum++;
}
int vis[Nmax];
bool dfs(int now, int ban) {
  vis[now] = 1;
  for (int i = pEdge[now]; i > 0; i = edge[i].next) {
    if (i == ban) continue;
    int next = edge[i].t2;
    path[pathNum++] = i;
    if (vis[next] == 1) {
      if (ban == -1) {
        do banId[banNum++] = path[--pathNum];
        while (edge[path[pathNum]].t1 != next);
      }
      pathNum = 0;
      return false;
    } else if (vis[next] == 0 && !dfs(next, ban))
      return false;
    pathNum--;
  }
  vis[now] = 2;
  return true;
}
int main() {
  scanf("%d%d", &n, &m);
  edgeNum = 1;
  pathNum = 0;
  while (m--) {
    int t1, t2;
    scanf("%d%d", &t1, &t2);
    addEdge(t1, t2);
  }
  bool flag = true;
  for (int i = 1; i < n && flag; i++)
    if (!vis[i]) flag = dfs(i, -1);
  for (int i = 0; i < banNum && !flag; i++) {
    memset(vis, 0, sizeof(vis));
    flag = true;
    for (int j = 1; j < n && flag; j++)
      if (!vis[j]) flag = dfs(j, banId[i]);
  }
  printf("%s\n", flag ? "YES" : "NO");
  return 0;
}
