#include <bits/stdc++.h>
using namespace std;
void input(long long n, long long a[]) {
  for (int i = 0; i < n; ++i) cin >> a[i];
}
long long bin_expo(long long A, long long B, long long M) {
  long long res = 1LL;
  while (B > 0) {
    if (B % 2 == 1) {
      res = (res * A) % M;
    }
    A = (A * A) % M;
    B = B / 2;
  }
  return res;
}
bool isPrime[1000000 + 1];
void sieve() {
  int i, j;
  memset(isPrime, true, sizeof(isPrime));
  for (i = 2; i * i <= 1000000; i++) {
    if (isPrime[i] == true) {
      for (j = i * i; j <= 1000000; j = j + i) isPrime[j] = false;
    }
  }
}
vector<long long> adj[505];
bool visited[505], finished[505];
long long count1[505], graph[505][505];
vector<long long> path;
vector<long long> ans[250000];
long long cycles;
long long n, m, x, y;
void go(long long u) {
  long long sz = path.size();
  while (sz != 0 && u != path[sz - 1]) {
    ans[cycles].push_back(path[sz - 1]);
    sz--;
  }
  ans[cycles].push_back(u);
}
void dfs(long long s) {
  if (finished[s]) return;
  if (visited[s]) {
    go(s);
    cycles++;
    return;
  }
  visited[s] = 1;
  path.push_back(s);
  for (auto it : adj[s]) {
    dfs(it);
  }
  visited[s] = 0;
  finished[s] = 1;
  path.pop_back();
}
bool visit[505];
bool recStack[505];
bool isCyclicUtil(int v) {
  if (visit[v] == false) {
    visit[v] = true;
    recStack[v] = true;
    for (int i = 1; i <= n; i++) {
      if (i != v && graph[v][i] && !visit[i] && isCyclicUtil(i)) {
        return true;
      } else if (i != v && graph[v][i] && recStack[i])
        return true;
    }
  }
  recStack[v] = false;
  return false;
}
bool isCyclic() {
  memset(visit, false, sizeof(visit));
  memset(recStack, false, sizeof(recStack));
  for (int i = 1; i <= n; i++)
    if (isCyclicUtil(i)) return true;
  return false;
}
int main() {
  scanf("%lld", &n);
  scanf("%lld", &m);
  memset(graph, 0, sizeof(graph));
  for (int i = 0; i < m; ++i) {
    scanf("%lld", &x);
    scanf("%lld", &y);
    adj[x].push_back(y);
    graph[x][y] = 1;
  }
  for (long long i = 1; i <= n; i++) {
    if (!finished[i]) {
      dfs(i);
    }
  }
  if (cycles == 0 || cycles == 1) {
    cout << "YES" << endl;
    return 0;
  }
  for (int i = ans[0].size() - 1; i > 0; i--) {
    graph[ans[0][i]][ans[0][i - 1]] = 0;
    if (!isCyclic()) {
      cout << "YES" << endl;
      return 0;
    }
    graph[ans[0][i]][ans[0][i - 1]] = 1;
  }
  cout << "NO" << endl;
  return 0;
}
