#include <bits/stdc++.h>
using namespace std;
int unused_from, unused_to;
vector<int> G[100000];
vector<int> Grev[100000];
bool used[100000] = {};
int ord[100000], lowlink[100000];
int k = 0;
void dfs(int v, int prev) {
  used[v] = true;
  ord[v] = lowlink[v] = k;
  k++;
  for (long long i = 0; i < (long long)(Grev[v].size()); i++) {
    int to = Grev[v][i];
    if ((v == unused_from && to == unused_to) ||
        (v == unused_to && to == unused_from))
      continue;
    if (!used[to]) {
      dfs(to, v);
      lowlink[v] = min(lowlink[v], lowlink[to]);
    } else if (used[to] && to != prev) {
      lowlink[v] = min(lowlink[v], ord[to]);
    }
  }
}
vector<pair<int, int> > enumerateBridge(int e, vector<pair<int, int> > edges) {
  vector<pair<int, int> > ret;
  for (long long i = 0; i < (long long)(e); i++) {
    int a = edges[i].first, b = edges[i].second;
    if ((a == unused_from && b == unused_to) ||
        (a == unused_to && b == unused_from))
      continue;
    if (ord[a] > ord[b]) swap(a, b);
    if (ord[a] < lowlink[b])
      ret.push_back(pair<int, int>(edges[i].first, edges[i].second));
  }
  return ret;
}
bool hasLoop(int v) {
  vector<int> in_deg(v, 0);
  for (long long i = 0; i < (long long)(10000); i++) {
    for (long long j = 0; j < (long long)(G[i].size()); j++) {
      int from = i, to = G[i][j];
      if (from == unused_from && to == unused_to) continue;
      in_deg[to]++;
    }
  }
  stack<int> st;
  vector<int> list;
  for (long long i = 0; i < (long long)(v); i++)
    if (in_deg[i] == 0) st.push(i);
  while (st.size()) {
    int q = st.top();
    st.pop();
    list.push_back(q);
    for (long long i = 0; i < (long long)(G[q].size()); i++) {
      int to = G[q][i];
      if (q == unused_from && to == unused_to) continue;
      in_deg[to]--;
      if (in_deg[to] == 0) st.push(to);
    }
  }
  if (list.size() != v) return true;
  return false;
}
int main() {
  int v, e;
  cin >> v >> e;
  vector<pair<int, int> > edges;
  for (long long i = 0; i < (long long)(e); i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    edges.push_back(pair<int, int>(a, b));
    G[a].push_back(b);
    Grev[a].push_back(b), Grev[b].push_back(a);
  }
  dfs(0, -1);
  vector<pair<int, int> > bridge_list = enumerateBridge(e, edges);
  map<pair<int, int>, bool> mp;
  for (long long i = 0; i < (long long)(bridge_list.size()); i++)
    mp[bridge_list[i]] = true;
  for (long long i = 0; i < (long long)(10000); i++) {
    for (long long j = 0; j < (long long)(G[i].size()); j++) {
      unused_from = i;
      unused_to = G[i][j];
      for (long long i = 0; i < (long long)(10000); i++) used[i] = false;
      k = 0;
      dfs(0, -1);
      vector<pair<int, int> > brg = enumerateBridge(e, edges);
      if (not mp[pair<int, int>(unused_from, unused_to)] && brg.size() >= 2 &&
          not hasLoop(v)) {
        cout << "YES" << endl;
        return 0;
      }
    }
  }
  cout << "NO" << endl;
}
