#include <bits/stdc++.h>
using namespace std;
using LLI = long long;
long long NWD(long long a, long long b) { return (b == 0) ? a : NWD(b, a % b); }
long long NWW(long long a, long long b) { return a / NWD(a, b) * b; }
const int N = 1e6 + 400, LOGN = 21;
int n, m, cntS, In[N], Out[N];
vector<int> G[N], H[LOGN];
set<int> zbior;
bool odw[N];
void DFS(int u) {
  odw[u] = true;
  if (Out[u] == 0) H[cntS].push_back(u);
  for (auto v : G[u])
    if (odw[v] == false) DFS(v);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (int i = (1); i <= (m); i++) {
    int a, b;
    cin >> a >> b;
    G[a].push_back(b);
    In[b]++;
    Out[a]++;
  }
  for (int i = (1); i <= (n); i++) {
    if (In[i] == 0) {
      DFS(i);
      cntS++;
      memset(odw, 0, sizeof odw);
    }
  }
  for (int maska = (1); maska <= ((1 << cntS) - 2); maska++) {
    zbior.clear();
    int ile = 0;
    for (int u = (0); u <= (cntS - 1); u++) {
      if (maska & (1 << u)) {
        ile++;
        for (auto v : H[u]) zbior.insert(v);
      }
    }
    if (ile >= ((int)(zbior).size())) return cout << "NO" << endl, 0;
  }
  cout << "YES" << endl;
  getchar();
  getchar();
  return 0;
}
