#include <bits/stdc++.h>
using namespace std;
const int MX = 1000005;
int n, m, u, v, d[MX], in[MX], cn = 0;
vector<int> adj[MX], s;
void dfs(int u) {
  if (adj[u].empty()) d[u] = 1 << cn++;
  for (int v : adj[u]) {
    if (!d[v]) dfs(v);
    d[u] |= d[v];
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  while (m--) {
    cin >> u >> v;
    adj[u].push_back(v);
    in[v]++;
  }
  for (int i = 1; i <= n; i++)
    if (!in[i]) {
      dfs(i);
      s.push_back(i);
    }
  n = s.size();
  for (int i = 1; i < (1 << n) - 1; i++) {
    int mk = 0;
    for (int j = 0; j < n; j++)
      if (i & (1 << j)) mk |= d[s[j]];
    if (__builtin_popcount(i) == __builtin_popcount(mk)) {
      cout << "NO" << '\n';
      return 0;
    }
  }
  cout << "YES" << '\n';
  return 0;
}
