#include <bits/stdc++.h>
using namespace std;
#pragma warning(disable : 4996)
const int N = 1e6 + 5, K = 20;
vector<int> v[N];
int num[N], sz[N], w[N], used[N];
bool g[N];
int z = 0;
void dfs(int node, int from) {
  used[node] = z;
  if (num[node] != -1) {
    w[1 << from] |= 1 << num[node];
    return;
  }
  for (int to : v[node]) {
    if (used[to] != z) {
      dfs(to, from);
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    v[a].push_back(b);
    g[b] = 1;
  }
  fill(num, num + n, -1);
  for (int i = 0, j = 0; i < n; i++) {
    if (v[i].empty()) {
      num[i] = j++;
    }
  }
  int k = 0;
  for (int i = 0; i < n; i++) {
    if (!g[i]) {
      z++;
      dfs(i, k++);
    }
  }
  for (int i = 0; i < k; i++) {
    sz[1 << i] = 1;
  }
  for (int i = 1; i < (1 << k); i++) {
    sz[i] = sz[i & -i] + sz[i ^ (i & -i)];
  }
  for (int i = 1; i < (1 << k) - 1; i++) {
    w[i] = w[i & -i] | w[i ^ (i & -i)];
    if (sz[w[i]] == sz[i]) {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES";
  return 0;
}
