#include <bits/stdc++.h>
using namespace std;
int indeg[510], vis[510], indeg1[510], vis1[510];
int n, m;
vector<vector<int> > adj(510);
int check(int x) {
  int i, c, p;
  queue<int> q;
  for (i = 0; i < n; i++) {
    vis1[i] = vis[i];
    indeg1[i] = indeg[i];
  }
  indeg1[x]--;
  q.push(x);
  c = 1;
  while (!q.empty()) {
    p = q.front();
    q.pop();
    for (i = 0; i < adj[p].size(); i++) {
      indeg1[adj[p][i]]--;
      if (indeg1[adj[p][i]] == 0 && vis1[adj[p][i]] == 0) {
        vis1[adj[p][i]] = 1;
        c++;
        q.push(adj[p][i]);
      }
    }
  }
  return c;
}
int toposort() {
  int i, c = 0, j, p;
  queue<int> q;
  vector<int> v;
  for (i = 0; i < n; i++) {
    indeg[i] = 0;
    vis[i] = 0;
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < adj[i].size(); j++) {
      indeg[adj[i][j]]++;
    }
  }
  for (i = 0; i < n; i++) {
    if (indeg[i] == 0) {
      q.push(i);
      vis[i] = 1;
      c++;
    }
  }
  while (!q.empty()) {
    p = q.front();
    q.pop();
    for (i = 0; i < adj[p].size(); i++) {
      indeg[adj[p][i]]--;
      if (indeg[adj[p][i]] == 0 && vis[adj[p][i]] == 0) {
        vis[adj[p][i]] = 1;
        c++;
        q.push(adj[p][i]);
      }
    }
  }
  if (c == n) {
    cout << "YES" << endl;
    exit(0);
  } else {
    for (i = 0; i < n; i++) {
      if (indeg[i] == 1) {
        v.push_back(i);
      }
    }
    if (v.size() == 0) {
      cout << "NO" << endl;
      exit(0);
    } else {
      for (i = 0; i < v.size(); i++)
        if (check(v[i]) + c == n) {
          cout << "YES" << endl;
          exit(0);
        }
      cout << "NO" << endl;
      exit(0);
    }
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  int u, v, i;
  cin >> n >> m;
  for (i = 0; i < m; i++) {
    cin >> u >> v;
    u--;
    v--;
    adj[u].push_back(v);
  }
  toposort();
}
