#include <bits/stdc++.h>
#pragma GCC optimize("O2,unroll-loops")
using namespace std;
const long double eps = 1e-7;
const int inf = 1000000010;
const long long INF = 10000000000000010LL;
const int mod = 1000000007;
const int MAXN = 1000010, N = 20;
int n, m, k, u, v, x, y, t, a, b, ans;
int A[MAXN], src[N], snk[N], adj[1 << N];
bool mark[MAXN];
vector<int> G[MAXN];
void dfs(int node) {
  mark[node] = 1;
  for (int v : G[node])
    if (!mark[v]) dfs(v);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  if (n == 1) return cout << "YES" << '\n', 0;
  while (m--) {
    cin >> u >> v;
    G[u].push_back(v);
    mark[v] = 1;
  }
  for (int i = 1; i <= n; i++)
    if (!mark[i]) src[t++] = i;
  for (int i = 1; i <= n; i++)
    if (G[i].empty()) snk[k++] = i;
  for (int i = 0; i < k; i++) {
    memset(mark, 0, sizeof(mark));
    dfs(src[i]);
    for (int j = 0; j < k; j++)
      if (mark[snk[j]]) adj[i] |= (1 << j);
  }
  for (int mask = 1; mask < (1 << k) - 1; mask++) {
    int NS = 0;
    for (int i = 0; i < k; i++)
      if (mask & (1 << i)) NS |= adj[i];
    if (__builtin_popcount(NS) <= __builtin_popcount(mask))
      return cout << "NO" << '\n', 0;
  }
  cout << "YES\n";
  return 0;
}
