You are given a [directed graph](https://en.wikipedia.org/wiki/Directed_graph) consisting of n vertices and m edges (each edge is directed, so it can be traversed in only one direction). You are allowed to remove at most one edge from it.

Can you make this graph [acyclic](https://en.wikipedia.org/wiki/Directed_acyclic_graph) by removing at most one edge from it? A directed graph is called acyclic iff it doesn't contain any cycle (a non-empty path that starts and ends in the same vertex).

Input

The first line contains two integers n and m (2 ≤ n ≤ 500, 1 ≤ m ≤ min(n(n - 1), 100000)) — the number of vertices and the number of edges, respectively.

Then m lines follow. Each line contains two integers u and v denoting a directed edge going from vertex u to vertex v (1 ≤ u, v ≤ n, u ≠ v). Each ordered pair (u, v) is listed at most once (there is at most one directed edge from u to v).

Output

If it is possible to make this graph acyclic by removing at most one edge, print YES. Otherwise, print NO.

Examples

Input

3 4
1 2
2 3
3 2
3 1


Output

YES


Input

5 6
1 2
2 3
3 2
3 1
2 1
4 5


Output

NO

Note

In the first example you can remove edge <image>, and the graph becomes acyclic.

In the second example you have to remove at least two edges (for example, <image> and <image>) in order to make the graph acyclic.
#include <bits/stdc++.h>
using namespace std;
vector<char> cl, used;
vector<int> p;
int cycle_st, cycle_end, st;
vector<int> g[510];
int xx, yy;
bool dfs(int v) {
  cl[v] = 1;
  for (size_t i = 0; i < g[v].size(); ++i) {
    int to = g[v][i];
    if (cl[to] == 0) {
      p[to] = v;
      if (dfs(to)) return true;
    } else if (cl[to] == 1) {
      cycle_end = v;
      cycle_st = to;
      return true;
    }
  }
  cl[v] = 2;
  return false;
}
bool dfs2(int v) {
  used[v] = 1;
  for (size_t i = 0; i < g[v].size(); ++i) {
    int to = g[v][i];
    if (used[to] == 0) {
      if (dfs2(to)) return true;
    } else if (used[to] == 1) {
      cycle_end = v;
      cycle_st = to;
      return true;
    }
  }
  used[v] = 2;
  return false;
}
bool dfs3(int v) {
  cl[v] = 1;
  for (size_t i = 0; i < g[v].size(); ++i) {
    int to = g[v][i];
    if (xx == v && to == yy) continue;
    if (cl[to] == 0) {
      if (dfs3(to)) return true;
    } else if (cl[to] == 1) {
      cycle_end = v;
      st = to;
      return true;
    }
  }
  cl[v] = 2;
  return false;
}
int main() {
  ios_base::sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    g[x].push_back(y);
  }
  p.assign(n, -1);
  cl.assign(n, 0);
  used.assign(n, 0);
  cycle_st = -1;
  for (int i = 0; i < n; ++i)
    if (dfs(i)) break;
  if (cycle_st == -1) {
    cout << "YES";
    return 0;
  }
  used.assign(n, 0);
  used[cycle_st] = 2;
  for (int v = cycle_end; v != cycle_st; v = p[v]) used[v] = 2;
  for (int i = 0; i < n; ++i) {
    int pr = used[i];
    if (dfs2(i)) {
      cout << "NO";
      return 0;
    }
    used[i] = pr;
  }
  for (int v = cycle_end; v != cycle_st; v = p[v]) {
    yy = v, xx = p[v];
    cl.assign(n, 0);
    st = -1;
    for (int i = 0; i < n; ++i) {
      if (dfs3(i)) break;
    }
    if (st == -1) {
      cout << "YES";
      return 0;
    }
  }
  yy = cycle_st, xx = cycle_end;
  cl.assign(n, 0);
  st = -1;
  for (int i = 0; i < n; ++i) {
    if (dfs3(i)) break;
  }
  if (st == -1) {
    cout << "YES";
    return 0;
  }
  cout << "NO";
  return 0;
}
