#include <bits/stdc++.h>
using namespace std;
vector<int> G[510];
int ind[510], cind[510];
bool topo(int n) {
  queue<int> Q;
  for (int i = 1; i <= n; i++) {
    cind[i] = ind[i];
    if (ind[i] <= 0) Q.push(i);
  }
  int cnt = 0;
  while (!Q.empty()) {
    int u = Q.front();
    Q.pop();
    cnt++;
    for (int i = 0; i < G[u].size(); i++) {
      int v = G[u][i];
      cind[v]--;
      if (cind[v] == 0) Q.push(v);
    }
  }
  return cnt == n;
}
int main() {
  int n, m, u, v;
  scanf("%d%d", &n, &m);
  while (m--) {
    scanf("%d%d", &u, &v);
    G[u].push_back(v);
    ind[v]++;
  }
  for (int i = 1; i <= n; i++) {
    ind[i]--;
    if (topo(n)) {
      printf("YES");
      return 0;
    }
    ind[i]++;
  }
  printf("NO");
  return 0;
}
