#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int INF = 0x3f3f3f3f;
const int MOD = 1e8;
const int N = 5e2 + 5;
const int dir[4][2] = {-1, 0, 1, 0, 0, -1, 0, 1};
int e[N][N];
int in[N], cnt[N];
int n, m;
bool flag;
void init() {
  memset(e, 0, sizeof(e));
  memset(cnt, 0, sizeof(cnt));
  flag = 0;
}
bool topp() {
  queue<int> que;
  int num = 0;
  for (int i = 1; i < n + 1; i++)
    if (!in[i]) que.push(i), num++;
  while (!que.empty()) {
    int front = que.front();
    que.pop();
    for (int i = 1; i < n + 1; i++) {
      if (e[front][i] && in[i]) {
        in[i]--;
        if (!in[i]) que.push(i), num++;
      }
    }
  }
  return num == n;
}
int main() {
  ios::sync_with_stdio(false);
  while (cin >> n >> m) {
    init();
    for (int i = 0; i < m; i++) {
      int u, v;
      cin >> u >> v;
      e[u][v] = 1;
      cnt[v]++;
    }
    for (int i = 1; i < n + 1; i++) {
      if (!cnt[i]) continue;
      memcpy(in, cnt, sizeof(cnt));
      in[i]--;
      if (topp()) {
        flag = 1;
        cout << "YES" << endl;
        break;
      }
    }
    if (!flag) cout << "NO" << endl;
  }
  return 0;
}
