#include <bits/stdc++.h>
using namespace std;
const int N = 505;
vector<int> G[N];
int n, m, in[N], d[N];
int topuSort(int s) {
  memcpy(in, d, sizeof(d));
  queue<int> p;
  in[s]--;
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (!in[i]) p.push(i);
  }
  while (!p.empty()) {
    cnt++;
    int u = p.front();
    p.pop();
    for (int i = 0; i < G[u].size(); i++) {
      int v = G[u][i];
      in[v]--;
      if (!in[v]) p.push(v);
    }
  }
  return cnt == n;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    G[a].push_back(b);
    d[b]++;
  }
  int flag = 0;
  for (int i = 1; i <= n; i++) {
    if (topuSort(i)) {
      flag = 1;
      break;
    }
  }
  if (flag)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
