#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
void D() { cerr << endl; }
string to_string(string s) { return s; }
string to_string(const char* s) { return (string)s; }
string to_string(char s) {
  string res = "";
  res += s;
  return res;
}
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename T, typename S>
string to_string(pair<T, S> p) {
  return "(" + to_string(p.first) + "," + to_string(p.second) + ")";
}
template <typename T>
string to_string(T v) {
  bool first = true;
  string res = "";
  for (auto i = v.begin(); i != v.end(); ++i) {
    res += to_string(*i);
    res += " \n"[i == v.end() - 1];
  }
  return res;
}
template <typename T, typename S>
string to_string(map<T, S> p) {
  bool first = true;
  string res = "";
  for (const auto& x : p) {
    if (!first) {
      res += ",";
    }
    first = false;
    res += ("(" + to_string(x.first) + "," + to_string(x.second) + ")");
  }
  return res;
}
template <typename T, typename... S>
void D(T H, S... X) {
  cerr << " " << to_string(H);
  D(X...);
}
template <typename T, typename S>
bool amin(T& a, const S& b) {
  return a > b ? a = b, 1 : 0;
}
template <typename T, typename S>
bool amax(T& a, const S& b) {
  return a < b ? a = b, 1 : 0;
}
ll inf = 1e18, mod = 1e9 + 7, maxn = 200001;
const int N = 501;
int n, m, d[N], a[N];
vector<int> g[N];
bool topological(int x) {
  for (int i = 0; i <= n; ++i) {
    a[i] = d[i];
  }
  int num = 0;
  a[x]--;
  queue<int> q;
  for (int i = 1; i <= n; i++)
    if (a[i] == 0) q.push(i), num++;
  while (!q.empty()) {
    int i = q.front();
    q.pop();
    for (int j = 0; j < g[i].size(); j++)
      if (!(--a[g[i][j]])) q.push(g[i][j]), num++;
  }
  cerr << "["
       << "num, n"
       << "]:",
      D(num, n);
  return num == n;
}
void solve() {
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;
    d[v]++;
    g[u].push_back(v);
  }
  for (ll i = 1; i <= n; i += (1))
    if (topological(i)) {
      cout << to_string("YES") << endl;
      return;
    }
  cout << to_string("NO") << endl;
  return;
}
int main() {
  int _(1);
  while (_--) {
    solve();
  }
  return 0;
}
