#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
int n, ne;
vector<int> g[N];
int degIn[N], degOut[N];
int id[N];
vector<int> src, snk;
int adj[20];
bool was[N];
void dfs(int u, int s) {
  was[u] = 1;
  if (degOut[u] == 0) {
    adj[s] |= (1 << id[u]);
  }
  for (int v : g[u]) {
    if (not was[v]) {
      dfs(v, s);
    }
  }
}
int main() {
  ios ::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> ne;
  for (int ie = 1; ie <= ne; ie++) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    degOut[u]++;
    degIn[v]++;
  }
  for (int u = 1; u <= n; u++) {
    if (degIn[u] == 0) {
      src.push_back(u);
    }
    if (degOut[u] == 0) {
      id[u] = snk.size();
      snk.push_back(u);
    }
  }
  for (int i = 0; i < src.size(); i++) {
    int u = src[i];
    if (degIn[u] == 0) {
      memset(was, 0, sizeof(was));
      dfs(u, i);
    }
  }
  int nSour = src.size();
  for (int mask = 1; mask < (1 << nSour); mask++) {
    int maskAdj = 0;
    for (int u = 0; u < nSour; u++) {
      if ((mask >> u) & 1) {
        maskAdj |= adj[u];
      }
    }
    if (__builtin_popcount(mask) < nSour &&
        __builtin_popcount(mask) == __builtin_popcount(maskAdj)) {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
  return 0;
}
