#include <bits/stdc++.h>
using namespace std;
struct edges {
  int to, next;
} edge[1010101];
int first[1010101], now;
void adde(int x, int y) {
  now++;
  edge[now].to = y;
  edge[now].next = first[x];
  first[x] = now;
}
int d1[1010101], d2[1010101];
int z[1010101], v[22];
int dn[1 << 20];
queue<int> q;
int main() {
  int n, m, x, y, cnt = 0, p;
  scanf("%d%d", &n, &m);
  memset(d1, 0, sizeof(d1));
  memset(d2, 0, sizeof(d2));
  memset(first, 0, sizeof(first));
  now = 0;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &x, &y);
    adde(y, x);
    d1[x]++;
    d2[y]++;
  }
  memset(z, 0, sizeof(z));
  for (int i = 1; i <= n; i++)
    if (d1[i] == 0) {
      z[i] = (1 << cnt);
      q.push(i);
      cnt++;
    }
  while (!q.empty()) {
    p = q.front();
    q.pop();
    for (int e = first[p]; e; e = edge[e].next) {
      d1[edge[e].to]--;
      z[edge[e].to] |= z[p];
      if (d1[edge[e].to] == 0) q.push(edge[e].to);
    }
  }
  cnt = 0;
  for (int i = 1; i <= n; i++)
    if (d2[i] == 0) v[cnt++] = z[i];
  dn[0] = 0;
  for (int i = 1; i < (1 << cnt); i++) dn[i] = dn[i >> 1] + (i & 1);
  int vv = 0;
  for (int i = 1; i < (1 << cnt) - 1; i++) {
    vv = 0;
    for (int j = 0; j < cnt; j++)
      if (i & (1 << j)) vv |= v[j];
    if (dn[vv] <= dn[i]) {
      printf("NO");
      return 0;
    }
  }
  printf("YES");
  return 0;
}
