#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 15;
vector<int> g[N];
int n, m;
bool vst[N], notSource[N], sinc[N];
set<int> match[N];
vector<int> src;
void dfs(int pos, int root) {
  if (vst[pos]) return;
  vst[pos] = 1;
  if (sinc[pos]) match[root].insert(pos);
  for (int i : g[pos]) dfs(i, root);
}
string toBit(int x) {
  string s = "";
  for (int i = 0; i < src.size(); i++)
    if (x & (1 << i))
      s += '1';
    else
      s += '0';
  return s;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    g[a - 1].push_back(b - 1);
    notSource[b - 1] = true;
  }
  for (int i = 0; i < n; i++) {
    if (!g[i].size()) sinc[i] = true;
    if (!notSource[i]) src.push_back(i);
  }
  for (int i : src) {
    dfs(i, i);
    memset(vst, 0, sizeof(vst));
  }
  for (int i = 1; i < (1 << src.size()) - 1; i++) {
    set<int> ac;
    for (int j = 0; j < src.size(); j++) {
      if (i & (1 << j)) {
        for (int k : match[src[j]]) ac.insert(k);
      }
    }
    if (ac.size() <= __builtin_popcount(i)) return !(cout << "NO" << endl);
  }
  cout << "YES" << endl;
}
