#include <bits/stdc++.h>
using namespace std;
map<pair<int, int>, int> mp;
vector<int> v[505];
int n, m, x, y, memo[505], memo2[505], ci[505];
long long may, cont;
bool b1 = false;
pair<int, int> esc;
void dfs(int nodo, int pos) {
  if (b1 == true) return;
  for (int i = 0; i < v[nodo].size() and b1 == false; i++) {
    if (memo[v[nodo][i]] > 0) {
      cont++;
      ci[pos] = v[nodo][i];
      for (int i1 = memo[v[nodo][i]]; i1 < pos; i1++) {
        mp[{ci[i1], ci[i1 + 1]}];
      }
      b1 = true;
    } else if (memo2[nodo] != 2) {
      if (memo2[v[nodo][i]] == 0) memo2[v[nodo][i]] = 1;
      ci[pos] = v[nodo][i];
      memo[v[nodo][i]] = pos;
      dfs(v[nodo][i], pos + 1);
      memo[v[nodo][i]] = 0;
    }
  }
  memo2[nodo] = 2;
  return;
}
void comprueba(int nodo) {
  if (b1 == true) return;
  for (int i = 0; i < v[nodo].size(); i++) {
    if (nodo == esc.first and v[nodo][i] == esc.second) {
    } else {
      if (memo[v[nodo][i]] > 0) {
        b1 = true;
      } else if (memo2[nodo] != x) {
        memo[v[nodo][i]] = 1;
        comprueba(v[nodo][i]);
        memo[v[nodo][i]] = 0;
      }
    }
  }
  memo2[nodo] = x;
  return;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &x, &y);
    v[x].push_back(y);
  }
  for (int i = 1; i <= n and b1 == false; i++) {
    if (memo2[i] == 0) {
      memo[i] = 1;
      ci[1] = i;
      dfs(i, 2);
      memo[i] = 0;
    }
  }
  x = 10;
  for (auto mpp : mp) {
    esc = mpp.first;
    b1 = false;
    x++;
    for (auto mpp2 : mp) {
      if (memo2[mpp2.first.first] != x) {
        memo[mpp2.first.first] = 1;
        comprueba(mpp2.first.first);
        memo[mpp2.first.first] = 0;
      }
    }
    if (b1 == false) break;
  }
  b1 = false;
  x++;
  for (int i = 1; i <= n; i++) {
    if (memo2[i] != x) {
      memo[i] = 1;
      comprueba(i);
      memo[i] = 0;
    }
  }
  if (b1 == true) {
    cout << "NO";
  } else
    cout << "YES";
  return 0;
}
