#include <bits/stdc++.h>
using namespace std;
struct node {
  int x;
  node *nxt;
} edge[1000010];
node *head[1000010], *ncnt = edge;
void add_edge(int x, int y) {
  ncnt++;
  ncnt->x = y;
  ncnt->nxt = head[x];
  head[x] = ncnt;
}
bool ind[1000010];
int n, m;
vector<int> src, snk;
bool vis[1000010];
void dfs(int x) {
  vis[x] = 1;
  for (node *v = head[x]; v != NULL; v = v->nxt) {
    int u = v->x;
    if (vis[u] == 0) dfs(u);
  }
}
int reach[1000010];
int main() {
  scanf("%d%d", &n, &m);
  int u, v;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &u, &v);
    add_edge(u, v);
    ind[v] = 1;
  }
  for (int i = 1; i <= n; i++) {
    if (head[i] == NULL) snk.push_back(i);
    if (ind[i] == 0) src.push_back(i);
  }
  for (int i = 0; i < src.size(); i++) {
    memset(vis, 0, sizeof vis);
    dfs(src[i]);
    for (int j = 0; j < snk.size(); j++)
      if (vis[snk[j]] == 1) reach[i] |= (1 << j);
  }
  int m = src.size();
  bool flag = 1;
  for (int i = 0; i < (1 << m); i++) {
    int res = 0;
    for (int j = 0; j < m; j++)
      if (i & (1 << j)) res |= reach[j];
    int x = __builtin_popcount(i);
    int y = __builtin_popcount(res);
    if (x > y || (x == y && x != 0 && x != m)) flag = 0;
  }
  if (flag)
    printf("YES");
  else
    printf("NO");
}
