#include <bits/stdc++.h>
using namespace std;
const int N = 1000010;
int n, m, in[N], u, v, cur[N], cnt = 0;
vector<int> g[N], v1;
bool vis[N];
void DFS(int node) {
  vis[node] = true;
  for (int i = 0; i < (int)g[node].size(); i++) {
    if (!vis[g[node][i]]) DFS(g[node][i]);
    cur[node] |= cur[g[node][i]];
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &u, &v);
    g[u].push_back(v);
    in[v]++;
  }
  for (int i = 1; i <= n; i++) {
    if (in[i] == 0) v1.push_back(i);
    if ((int)g[i].size() == 0) {
      cur[i] = (1 << cnt);
      cnt++;
      vis[i] = true;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (vis[i] == false) DFS(i);
  }
  n = (int)v1.size();
  assert(cnt == n);
  int tmp = 0, tmp2 = 0, tmp3 = 0;
  for (int mask = 1; mask < (1 << n); mask++) {
    tmp = tmp2 = tmp3 = 0;
    for (int j = 0; j < n; j++) {
      if (((mask >> j) & 1) == 1) {
        tmp2++;
        tmp |= cur[v1[j]];
      }
    }
    for (int j = 0; j < n; j++) {
      if (((tmp >> j) & 1) == 1) tmp3++;
    }
    if (tmp3 <= tmp2 && tmp2 != n) {
      puts("NO");
      return 0;
    }
  }
  puts("YES");
  return 0;
}
