#include <bits/stdc++.h>
using namespace std;
template <class T>
ostream &operator<<(ostream &os, vector<T> V) {
  os << "[";
  for (auto const &vv : V) os << vv << ",";
  os << "]";
  return os;
}
template <class L, class R>
ostream &operator<<(ostream &os, pair<L, R> P) {
  os << "(" << P.first << "," << P.second << ")";
  return os;
}
template <typename T>
inline void print_128(T num) {
  if (!num) return;
  print_128(num / 10);
  cout.put((num % 10) + '0');
}
inline int fstoi(const string &str) {
  auto it = str.begin();
  bool neg = 0;
  int num = 0;
  if (*it == '-')
    neg = 1;
  else
    num = *it - '0';
  ++it;
  while (it < str.end()) num = num * 10 + (*it++ - '0');
  if (neg) num *= -1;
  return num;
}
inline void getch(char &x) {
  while (x = getchar_unlocked(), x < 33) {
    ;
  }
}
inline void getstr(string &str) {
  str.clear();
  char cur;
  while (cur = getchar_unlocked(), cur < 33) {
    ;
  }
  while (cur > 32) {
    str += cur;
    cur = getchar_unlocked();
  }
}
template <typename T>
inline bool sc(T &num) {
  bool neg = 0;
  int c;
  num = 0;
  while (c = getchar_unlocked(), c < 33) {
    if (c == EOF) return false;
  }
  if (c == '-') {
    neg = 1;
    c = getchar_unlocked();
  }
  for (; c > 47; c = getchar_unlocked()) num = num * 10 + c - 48;
  if (neg) num *= -1;
  return true;
}
template <typename T, typename... Args>
inline void sc(T &num, Args &...args) {
  bool neg = 0;
  int c;
  num = 0;
  while (c = getchar_unlocked(), c < 33) {
    ;
  }
  if (c == '-') {
    neg = 1;
    c = getchar_unlocked();
  }
  for (; c > 47; c = getchar_unlocked()) num = num * 10 + c - 48;
  if (neg) num *= -1;
  sc(args...);
}
vector<int> adj[500];
vector<int> adj2[500];
bool vis[500];
int S[500];
int sid;
vector<vector<int>> scc;
int which[500];
void dfs1(int cur) {
  vis[cur] = 1;
  for (auto &i : adj[cur]) {
    if (!~i) continue;
    if (!vis[i]) {
      dfs1(i);
    }
  }
  S[--sid] = cur;
}
void dfs2(int cur) {
  vis[cur] = 1;
  which[cur] = scc.size() - 1;
  for (auto &i : adj2[cur]) {
    if (!vis[i]) {
      dfs2(i);
    }
  }
  scc.back().push_back(cur);
}
int nvis[500];
int curcnt;
int dfs3(int cur) {
  nvis[cur] = 1;
  for (auto &i : adj[cur]) {
    if (!~i) continue;
    if (nvis[i] == 1) return 1;
    if (!nvis[i]) {
      if (dfs3(i) == 1) return 1;
    }
  }
  nvis[cur] = 2;
  return 0;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  memset(which, 127, 2000);
  int n, m;
  sc(n, m);
  int f, s;
  static bool mat[500][500];
  bool alr = 0;
  std::pair<int, int> disc;
  while (m--) {
    sc(f, s);
    --f, --s;
    if (mat[s][f]) {
      if (alr) {
        cout << "NO" << '\n';
        exit(0);
      }
      alr = 1;
      disc = {f, s};
    } else {
      adj[f].push_back(s);
      mat[f][s] = mat[s][f] = 1;
      adj2[s].push_back(f);
    }
  }
  sid = n;
  for (int i = (0); i < int((n)); ++i) {
    if (!vis[i]) {
      dfs1(i);
    }
  }
  memset(vis, 0, 500);
  for (int i = (0); i < int((n)); ++i) {
    if (!vis[S[i]]) {
      scc.push_back({});
      dfs2(S[i]);
      if (scc.back().size() == 1) scc.pop_back();
    }
  }
  if (scc.size() > 1) {
    cout << "NO" << '\n';
    exit(0);
  }
  if (scc.empty()) {
    cout << "YES" << '\n';
    exit(0);
  }
  if (alr) {
    adj[disc.second].erase(
        find(begin(adj[disc.second]), end(adj[disc.second]), disc.first));
    adj2[disc.first].erase(
        find(begin(adj2[disc.first]), end(adj2[disc.first]), disc.second));
    adj[disc.first].push_back(disc.second);
    adj2[disc.second].push_back(disc.first);
    sid = n;
    memset(vis, 0, 500);
    for (int i = (0); i < int((n)); ++i) {
      if (!vis[i]) {
        dfs1(i);
      }
    }
    memset(vis, 0, 500);
    for (int i = (0); i < int((n)); ++i) {
      if (!vis[S[i]]) {
        scc.push_back({});
        dfs2(S[i]);
        if (scc.back().size() == 1)
          scc.pop_back();
        else {
          {
            cout << "NO" << '\n';
            exit(0);
          }
        }
      }
    }
    {
      cout << "YES" << '\n';
      exit(0);
    }
  }
  for (int i = (0); i < int((n)); ++i)
    sort(begin(adj[i]), end(adj[i])), sort(begin(adj2[i]), end(adj2[i]));
  std::pair<int, int> r;
  std::vector<int> tmp = scc[0];
  std::vector<int> scc = tmp;
  for (int i = 0; i < (int)scc.size(); ++i) {
    for (auto it = adj[scc[i]].begin(); it < adj[scc[i]].end(); ++it) {
      if (!which[*it]) {
        bool g = 1;
        r = {scc[i], *it};
        int s = *it;
        *it = -1;
        memset(nvis, 0, 2000);
        for (int i = (0); i < int((n)); ++i) {
          if (!nvis[i]) {
            if (dfs3(i)) {
              g = 0;
              break;
            }
          }
        }
        if (g) {
          cout << "YES" << '\n';
          exit(0);
        }
        if (clock() / (double)CLOCKS_PER_SEC > 0.8) {
          cout << "NO" << '\n';
          exit(0);
        }
        *it = s;
      }
    }
  }
  cout << "NO";
}
