#include <bits/stdc++.h>
using namespace std;
const int N = 1000005;
vector<int> e[N], E[N], S, T;
int ok[25], vis[N], cnt[N * 2], n, m;
void dfs(int x) {
  if (vis[x]) return;
  vis[x] = 1;
  for (auto i : e[x]) dfs(i);
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = (int)(1); i <= (int)(m); i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    e[x].push_back(y);
    E[y].push_back(x);
  }
  for (int i = (int)(1); i <= (int)(n); i++) {
    if (!e[i].size()) T.push_back(i);
    if (!E[i].size()) S.push_back(i);
  }
  int sz = S.size();
  for (int i = (int)(0); i <= (int)(sz - 1); i++) {
    memset(vis, 0, sizeof(vis));
    dfs(S[i]);
    for (int j = (int)(0); j <= (int)(sz - 1); j++)
      if (vis[T[j]]) ok[i] |= 1 << j;
  }
  for (int i = (int)(0); i <= (int)((1 << sz) - 1); i++)
    cnt[i] = cnt[i / 2] + (i & 1);
  for (int i = (int)(0); i <= (int)((1 << sz) - 1); i++) {
    int res = 0;
    for (int j = (int)(0); j <= (int)(sz - 1); j++)
      if (i & (1 << j)) res |= ok[j];
    int cnt1 = cnt[i], cnt2 = cnt[res];
    if (cnt2 < cnt1 || (cnt2 == cnt1 && cnt1 != 0 && cnt1 != sz))
      return puts("NO"), 0;
  }
  puts("YES");
}
