#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int n, m;
vector<int> G[maxn], ts;
int pos[maxn], x;
bool mark[maxn], fr;
void dfs(int a) {
  mark[a] = 1;
  for (auto b : G[a]) {
    if ((!mark[b]) && (fr || b != x)) {
      dfs(b);
    }
    if (b == x) fr = 1;
  }
  pos[a] = ts.size();
  ts.push_back(a);
}
int s[maxn], t[maxn];
int32_t main() {
  scanf("%d%d", &n, &m);
  for (int i = int(0); i < int(m); i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--, b--;
    s[i] = a;
    t[i] = b;
    G[a].push_back(b);
  }
  for (; x < n; x++) {
    fill(mark, mark + n, 0);
    fr = 0;
    for (int i = int(0); i < int(n); i++) {
      if (!mark[i]) dfs(i);
    }
    int ans = 0;
    for (int i = int(0); i < int(m); i++) {
      ans += (pos[s[i]] < pos[t[i]]);
    }
    if (ans < 2) {
      printf("YES\n");
      return 0;
    }
  }
  printf("NO\n");
}
