#include <bits/stdc++.h>
using namespace std;
const int max_n = 1000011, log_n = 32, max_m = 21, mod = 1000000007,
          inf = 1011111111;
int n, m, s[max_m], f[max_m], matr[max_m], last_s, last_f, mtr[max_n];
vector<int> v[max_n], bv[max_n];
void dfs(int x) {
  for (int i = 0; i < v[x].size(); ++i) {
    if (mtr[v[x][i]] == 0) {
      dfs(v[x][i]);
    }
    mtr[x] |= mtr[v[x][i]];
  }
}
int get_bits(int x) {
  int ans = 0;
  while (x) {
    ans += x % 2;
    x /= 2;
  }
  return ans;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    --x;
    --y;
    v[x].push_back(y);
    bv[y].push_back(x);
  }
  for (int i = 0; i < n; ++i) {
    if (v[i].size() == 0) {
      mtr[i] = 1 << last_f;
      f[last_f++] = i;
    }
    if (bv[i].size() == 0) {
      s[last_s++] = i;
    }
  }
  for (int i = 0; i < last_s; ++i) {
    dfs(s[i]);
    matr[i] = mtr[s[i]];
  }
  bool ans = 1;
  for (int i = 1; i + 1 < (1 << last_s) - 1; ++i) {
    int all = 0, cnt = 0;
    for (int q = 0; q < last_s; ++q) {
      if (i & (1 << q)) {
        ++cnt;
        all |= matr[q];
      }
    }
    if (cnt >= get_bits(all)) {
      ans = 0;
    }
  }
  if (ans) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }
  return 0;
}
