#include <bits/stdc++.h>
const int N = 2333333;
int n, m, head[N], to[N], nxt[N], edgenum, ind[N], oud[N], dy[N], dfn, a[30];
void add(int u, int v) {
  to[++edgenum] = v;
  nxt[edgenum] = head[u];
  head[u] = edgenum;
}
inline int dfs(int u) {
  int res = dy[u] ? (1 << (dy[u] - 1)) : 0;
  for (int i = head[u]; i; i = nxt[i]) res |= dfs(to[i]);
  return res;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    add(u, v);
    ind[v]++;
    oud[u]++;
  }
  for (int i = 1; i <= n; i++)
    if (!oud[i]) dy[i] = ++dfn;
  dfn = 0;
  for (int i = 1; i <= n; i++)
    if (!ind[i]) a[++dfn] = dfs(i);
  for (int s = 1; s <= (1 << dfn) - 2; s++) {
    int cnt = 0, num = 0;
    for (int i = 1; i <= dfn; i++)
      num += (s >> i - 1) & 1, cnt += (s & a[i]) == a[i];
    if (cnt >= num) {
      puts("NO");
      return 0;
    }
  }
  puts("YES");
  return 0;
}
