#include <bits/stdc++.h>
using namespace std;
vector<int> adj[1000009];
int in[1000009], out[1000009];
bool vs[22][1000009];
void dfs(int x, int n) {
  vs[x][n] = 1;
  for (auto& it : adj[n])
    if (!vs[x][it]) dfs(x, it);
}
int main() {
  int N, M;
  scanf("%d%d", &N, &M);
  while (M--) {
    int u, v;
    scanf("%d%d", &u, &v);
    adj[u].push_back(v);
    in[v]++;
    out[u]++;
  }
  vector<int> src, snk;
  for (int i = 1; i <= N; i++) {
    if (in[i] == 0) src.push_back(i);
    if (out[i] == 0) snk.push_back(i);
  }
  int s = src.size();
  for (int i = 0; i < s; i++) {
    dfs(i, src[i]);
  }
  for (int i = 1; i < (1 << s) - 1; i++) {
    set<int> st;
    int c = 0;
    for (int j = 0; j < s; j++) {
      if (i & (1 << j)) {
        ++c;
        for (auto& it : snk)
          if (vs[j][it]) st.insert(it);
      }
    }
    if (c >= (int)st.size()) return !printf("NO");
  }
  puts("YES");
  return 0;
}
