#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
vector<int> v[maxn];
int n, m, in[maxn];
int idx[maxn], out[maxn];
bool check(int x) {
  for (int i = 1; i <= n; i++) in[i] = idx[i];
  in[x]--;
  queue<int> q;
  for (int i = 1; i <= n; i++) {
    if (in[i] == 0) q.push(i);
  }
  int num = 0;
  while (!q.empty()) {
    int s = q.front();
    q.pop();
    num++;
    for (int i = 0; i < out[s]; i++) {
      int t = v[s][i];
      in[t]--;
      if (in[t] == 0) {
        q.push(t);
      }
    }
  }
  return num == n;
}
void input() {
  cin >> n >> m;
  for (int i = 1, a, b; i <= m; i++) {
    cin >> a >> b;
    v[a].push_back(b);
    idx[b]++;
  }
  for (int i = 1; i <= n; i++) {
    out[i] = v[i].size();
  }
}
void work() {
  for (int i = 1; i <= n; i++) {
    if (check(i)) {
      puts("YES");
      return;
    }
  }
  puts("NO");
  return;
}
int main() {
  input();
  work();
  return 0;
}
