#include <bits/stdc++.h>
using namespace std;
int PI[1000];
int S[1000];
vector<int> G[1000];
int A, B;
bool dfs(int v) {
  bool cyc = false;
  S[v] = 1;
  for (int u : G[v]) {
    if (S[u] == 0) {
      PI[u] = v;
      cyc |= dfs(u);
    } else if (S[u] == 1) {
      A = u;
      B = v;
      cyc = true;
    }
  }
  S[v] = 2;
  return cyc;
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<pair<int, int> > edges;
  for (int i = (0); i < (m); i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    --a;
    --b;
    edges.push_back(make_pair(a, b));
    G[a].push_back(b);
  }
  for (int i = (0); i < (n); i++) {
    PI[i] = -1;
    S[i] = 0;
  }
  bool has_cycle = false;
  for (int i = (0); i < (n); i++) {
    if (S[i] == 0) {
      has_cycle |= dfs(i);
    }
  }
  if (!has_cycle) {
    printf("YES\n");
    return 0;
  }
  vector<pair<int, int> > cycle;
  cycle.push_back(make_pair(B, A));
  while (B != A) {
    cycle.push_back(make_pair(PI[B], B));
    B = PI[B];
  }
  for (int idx = (0); idx < (((int)(cycle).size())); idx++) {
    for (int i = (0); i < (n); i++) {
      G[i].clear();
      PI[i] = -1;
      S[i] = 0;
    }
    for (int i = (0); i < (((int)(edges).size())); i++) {
      if (edges[i].first != cycle[idx].first ||
          edges[i].second != cycle[idx].second) {
        G[edges[i].first].push_back(edges[i].second);
      }
    }
    has_cycle = false;
    for (int i = (0); i < (n); i++) {
      if (S[i] == 0) {
        has_cycle |= dfs(i);
      }
    }
    if (!has_cycle) {
      printf("YES\n");
      return 0;
    }
  }
  printf("NO\n");
}
