#include <bits/stdc++.h>
using namespace std;
const int N = 1e6;
int n, m, rem, id[N], msk[N];
bool bad[N], vis[N];
vector<int> g[N], may;
void no() {
  puts("NO");
  exit(0);
}
int dfs(int u) {
  int ret = 0;
  vis[u] = 1;
  if (g[u].empty()) ret = 1 << id[u];
  for (auto i : g[u])
    if (!vis[i]) ret |= dfs(i);
  return ret;
}
void calc(int i, int msk, int took) {
  if (i == may.size()) {
    if (took && took >= __builtin_popcount(msk) &&
        __builtin_popcount(msk) != rem)
      no();
    return;
  }
  calc(i + 1, msk | ::msk[may[i]], took + 1);
  calc(i + 1, msk, took);
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0, a, b; i < m; i++) {
    scanf("%d%d", &a, &b);
    g[--a].push_back(--b);
    bad[b] = 1;
  }
  for (int i = 0; i < n; i++) {
    if (!bad[i]) may.push_back(i);
    if (g[i].empty()) id[i] = rem++;
  }
  for (auto i : may) {
    memset(vis, 0, sizeof vis);
    msk[i] = dfs(i);
  }
  calc(0, 0, 0);
  puts("YES");
}
