#include <bits/stdc++.h>
using namespace std;
inline void dfs(int idx, const vector<vector<int> >& graph, vector<bool>& used,
                vector<int>& order) {
  if (used[idx]) return;
  used[idx] = true;
  for (int i = 0; i < graph[idx].size(); i++) {
    dfs(graph[idx][i], graph, used, order);
  }
  order.push_back(idx);
}
inline void rdfs(int idx, const vector<vector<int> >& rgraph, vector<int>& cmp,
                 const int& cnt) {
  cmp[idx] = cnt;
  for (int i = 0; i < rgraph[idx].size(); i++) {
    if (cmp[rgraph[idx][i]] == -1) rdfs(rgraph[idx][i], rgraph, cmp, cnt);
  }
}
size_t StronglyConnectedComponents(const vector<vector<int> >& graph,
                                   vector<int>& order) {
  size_t cnt = 0;
  vector<vector<int> > rgraph(graph.size());
  for (int i = 0; i < graph.size(); i++) {
    for (int j = 0; j < graph[i].size(); j++) {
      rgraph[graph[i][j]].push_back(i);
    }
  }
  vector<int> cmp;
  cmp.assign(graph.size(), -1);
  vector<bool> used(graph.size(), false);
  for (int i = 0; i < graph.size(); i++) {
    dfs(i, graph, used, order);
  }
  reverse(order.begin(), order.end());
  for (int i = 0; i < order.size(); i++) {
    if (cmp[order[i]] == -1) rdfs(order[i], rgraph, cmp, cnt), cnt++;
  }
  return cnt;
}
vector<vector<int> > g;
int depth[500];
int cnt[500];
int visited[500];
int ret;
void dfs(int pos, int prev) {
  visited[pos] = true;
  for (int i = 0; i < g[pos].size(); i++) {
    int to = g[pos][i];
    if (to == prev) continue;
    if (!visited[to]) {
      depth[to] = depth[pos] + 1;
      dfs(to, pos);
      cnt[pos] += cnt[to];
      if (cnt[to] == 0) ++ret;
    } else if (depth[to] < depth[pos]) {
      cnt[pos]++;
      cnt[to]--;
    }
  }
}
int main() {
  int N, M, A[1000], B[1000];
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    cin >> A[i] >> B[i];
    --A[i], --B[i];
  }
  g.resize(N);
  for (int i = 0; i < M; i++) {
    for (int j = 0; j < M; j++) {
      if (i == j) continue;
      g[A[j]].push_back(B[j]);
    }
    vector<int> order;
    if (N == StronglyConnectedComponents(g, order)) {
      memset(depth, 0, sizeof(depth));
      memset(cnt, 0, sizeof(cnt));
      memset(visited, 0, sizeof(visited));
      ret = 0;
      for (int j = 0; j < M; j++) {
        if (i != j) g[B[j]].push_back(A[j]);
      }
      for (int j = 0; j < N; j++) {
        if (!visited[j]) {
          ++ret;
          dfs(j, -1);
        }
      }
      if (ret >= 3) {
        cout << "YES" << endl;
        return (0);
      }
    }
    for (int j = 0; j < N; j++) g[j].clear();
  }
  cout << "NO" << endl;
}
