#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> v[1000005];
int in_[1000005];
int out_[1000005];
int vis[1000005];
int s[25];
int t[25];
int mask[25];
int num = 0;
void dfs(int x) {
  vis[x] = 1;
  for (auto u : v[x]) {
    if (vis[u] == 0) dfs(u);
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    v[a].push_back(b);
    in_[b] = 1;
    out_[a] = 1;
  }
  for (int i = 1; i <= n; i++) {
    if (in_[i] == 0) s[num++] = i;
  }
  num = 0;
  for (int i = 1; i <= n; i++) {
    if (out_[i] == 0) t[num++] = i;
  }
  for (int i = 0; i < num; i++) {
    memset(vis, 0, sizeof(vis));
    dfs(s[i]);
    for (int j = 0; j < num; j++) mask[i] |= vis[t[j]] << j;
  }
  for (int i = 1; i < (1 << num) - 1; i++) {
    int d = 0;
    for (int j = 0; j < num; j++) {
      if ((i >> j) & 1) d |= mask[j];
    }
    if (__builtin_popcount(i) >= __builtin_popcount(d))
      return printf("NO\n") * 0;
  }
  return printf("YES\n") * 0;
}
