#include <bits/stdc++.h>
using namespace std;
int n, m, a, b, c, cur;
vector<vector<int> > v, edge;
int val[30], inc[1000000 + 5];
bool visited[1000000 + 5];
void dfs(int now) {
  if (visited[now]) return;
  visited[now] = true;
  if (v[now].size() == 0)
    edge[cur].push_back(now);
  else {
    for (int i = 0; i < v[now].size(); i++) {
      dfs(v[now][i]);
    }
  }
}
void reset() {
  for (int i = 0; i < n; i++) visited[i] = false;
}
int main() {
  scanf("%d %d", &n, &m);
  v.resize(n + 5);
  edge.resize(25);
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &a, &b);
    a--;
    b--;
    v[a].push_back(b);
    inc[b]++;
  }
  for (int i = 0; i < n; i++) {
    if (inc[i] == 0) {
      val[cur] = i;
      c++;
      reset();
      dfs(i);
      cur++;
    }
  }
  int mask = (1 << c) - 1;
  for (int i = mask; i > 0; i = (i - 1) & mask) {
    if (i == mask) continue;
    int src = 0;
    set<int> sink;
    for (int j = 0; j < c; j++) {
      if ((1 << j) & i) {
        src++;
        for (int k = 0; k < edge[j].size(); k++) {
          sink.insert(edge[j][k]);
        }
      }
    }
    if (sink.size() <= src) {
      printf("NO\n");
      return 0;
    }
  }
  printf("YES\n");
}
