#include <bits/stdc++.h>
using namespace std;
const int N = 510, M = 1e5 + 10;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 1) + (x << 3) + (ch ^ 48);
    ch = getchar();
  }
  return x * f;
}
queue<int> que;
int in[N], tin[N];
vector<int> edge[N];
bool solve(int n) {
  int sum = 0, boot;
  for (int i = 1; i <= n; i++)
    if (!tin[i]) que.push(i), sum++;
  while (!que.empty()) {
    int x = que.front();
    que.pop();
    for (int i = 0; i < edge[x].size(); i++) {
      boot = edge[x][i];
      tin[boot]--;
      if (!tin[boot]) que.push(boot), sum++;
    }
  }
  return sum >= n;
}
int main() {
  int n, m;
  n = read(), m = read();
  int u, v;
  for (int i = 1; i <= m; i++) {
    u = read(), v = read();
    edge[u].push_back(v);
    in[v]++;
  }
  int boot;
  for (int i = 1; i <= n; i++) {
    if (in[i] > 0) {
      for (int j = 1; j <= n; j++) tin[j] = in[j];
      tin[i]--;
      if (solve(n)) {
        printf("YES");
        return 0;
      }
    }
  }
  printf("NO");
  return 0;
}
