#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 2;
const int M = 25;
vector<int> adj[N], lis[M];
bool used[M];
int deg1[N], num = 0, wow[M], idx[N];
void dfs(int x) {
  if (idx[x]) {
    lis[num].push_back(idx[x]);
  }
  for (int i = 0; i < adj[x].size(); i++) {
    dfs(adj[x][i]);
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, i, j, k, l, m;
  cin >> n >> m;
  for (i = 1; i <= m; i++) {
    cin >> j >> k;
    deg1[k]++;
    adj[j].push_back(k);
  }
  j = 0;
  for (i = 1; i <= n; i++) {
    if (!adj[i].size()) {
      j++;
      idx[i] = j;
    }
  }
  for (i = 1; i <= n; i++) {
    if (!deg1[i]) {
      num++;
      wow[num] = i;
      dfs(i);
    }
  }
  for (i = 1; i < (1 << num) - 1; i++) {
    for (j = 1; j <= num; j++) {
      used[j] = false;
    }
    for (j = 1; j <= num; j++) {
      if ((i & (1 << (j - 1)))) {
        for (k = 0; k < lis[j].size(); k++) {
          used[lis[j][k]] = true;
        }
      }
    }
    k = 0;
    for (j = 1; j <= num; j++) {
      if (used[j]) {
        k++;
      }
    }
    if (k <= __builtin_popcount(i)) {
      cout << "NO";
      exit(0);
    }
  }
  cout << "YES";
}
