#include <bits/stdc++.h>
using namespace std;
bool sc[((int)(1e6 + 5))], sn[((int)(1e6 + 5))];
int tot, mask[2 + (1 << 20)], arr[22];
vector<int> v[((int)(1e6 + 5))];
int dfs(int n) {
  if (mask[n] != 0) return mask[n];
  if (sn[n]) {
    mask[n] = 1 << tot;
    tot++;
  }
  for (int i = 0; i < v[n].size(); i++) {
    mask[n] |= dfs(v[n][i]);
  }
  return mask[n];
}
int main() {
  int n, m, tot = 0, i, j, a, b, cnt;
  scanf("%d %d", &n, &m);
  for (i = 1; i <= n; i++) sn[i] = sc[i] = 1;
  while (m--) {
    scanf("%d %d", &a, &b);
    v[a].push_back(b);
    sn[a] = sc[b] = 0;
  }
  for (i = 1; i <= n; i++) {
    if (sc[i]) {
      arr[tot] = dfs(i);
      tot++;
    }
  }
  for (i = 1; i < (1 << tot) - 1; i++) {
    mask[i] = 0;
    cnt = 0;
    for (j = 0; j < tot; j++) {
      if (i & (1 << j)) {
        mask[i] |= arr[j];
        cnt++;
      }
    }
    for (j = 0; j < tot; j++) {
      cnt -= (bool)(mask[i] & (1 << j));
    }
    if (cnt >= 0) {
      printf("NO\n");
      return 0;
    }
  }
  printf("YES\n");
  return 0;
}
