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.
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.Stack;
import java.util.ArrayList;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.NoSuchElementException;
import java.io.InputStream;
/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        boolean aCyclic(ArrayList<Integer>[] adj, int deleteFrom, int deleteTo) {
            int size = 0;
            int[] res = new int[adj.length];
            int[] incoming = new int[adj.length];
            for (int i = 0; i < adj.length; i++) {
                for (int incom : adj[i]) {
                    if (i != deleteFrom || incom != deleteTo) {
                        incoming[incom]++;
                    }
                }
            }
            for (int i = 0; i < adj.length; i++)
                if (incoming[i] == 0)
                    res[size++] = i;
            for (int i = 0; i < size; i++) {
                int cur = res[i];
                for (int nxt : adj[cur])
                    if (--incoming[nxt] == 0)
                        res[size++] = nxt;
            }
            return size == adj.length;
        }

        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.readInt();
            int m = in.readInt();
            int[] from = new int[m], to = new int[m];
            IOUtils.readIntArrays(in, from, to);
            MiscUtils.decreaseByOne(from, to);
            ArrayList<Integer>[] adj = new ArrayList[n];
            for (int i = 0; i < adj.length; i++) {
                adj[i] = new ArrayList<>();
            }
            for (int i = 0; i < from.length; i++) {
                adj[from[i]].add(to[i]);
            }
            DirectedCycle directedCycle = new DirectedCycle(new Digraph(adj));
            ArrayList<Integer> cycle = new ArrayList<>();
            if (!directedCycle.hasCycle()) {
                out.printLine("YES");
                return;
            }
            cycle.addAll(directedCycle.cycle);
            for (int i = 0; i < cycle.size() - 1; i++) {
                int deleteTo = cycle.get(i);
                int deleteFrom = cycle.get(i + 1);
                if (aCyclic(adj, deleteFrom, deleteTo)) {
                    out.printLine("YES");
                    return;
                }
            }
            out.printLine("NO");
        }

        public class Digraph {
            private final int V;
            private int E;
            private ArrayList<Integer>[] adj;
            private int[] indegree;

            public Digraph(int V) {
                if (V < 0) throw new IllegalArgumentException("Number of vertices in a Digraph must be nonnegative");
                this.V = V;
                this.E = 0;
                indegree = new int[V];
                adj = new ArrayList[V];
                for (int v = 0; v < V; v++) {
                    adj[v] = new ArrayList<>();
                }
            }

            public Digraph(ArrayList<Integer>[] adj) {
                try {
                    this.V = adj.length;
                    if (V < 0)
                        throw new IllegalArgumentException("number of vertices in a Digraph must be nonnegative");
                    indegree = new int[V];
                    this.adj = new ArrayList[V];
                    for (int v = 0; v < V; v++) {
                        this.adj[v] = new ArrayList<>();
                    }
                    for (int from = 0; from < adj.length; from++) {
                        for (int to : adj[from]) {
                            addEdge(from, to);
                        }
                    }
                } catch (NoSuchElementException e) {
                    throw new IllegalArgumentException("invalid input format in Digraph constructor", e);
                }
            }

            public int V() {
                return V;
            }

            private void validateVertex(int v) {
                if (v < 0 || v >= V)
                    throw new IllegalArgumentException("vertex " + v + " is not between 0 and " + (V - 1));
            }

            public void addEdge(int v, int w) {
                validateVertex(v);
                validateVertex(w);
                adj[v].add(w);
                indegree[w]++;
                E++;
            }

            public Iterable<Integer> adj(int v) {
                validateVertex(v);
                return adj[v];
            }
        }
        public class DirectedCycle {
            private boolean[] marked;
            private int[] edgeTo;
            private boolean[] onStack;
            private Stack<Integer> cycle;

            public DirectedCycle(Digraph G) {
                marked = new boolean[G.V()];
                onStack = new boolean[G.V()];
                edgeTo = new int[G.V()];
                for (int v = 0; v < G.V(); v++)
                    if (!marked[v] && cycle == null) dfs(G, v);
            }

            private void dfs(Digraph G, int v) {
                onStack[v] = true;
                marked[v] = true;
                for (int w : G.adj(v)) {
                    // short circuit if directed cycle found
                    if (cycle != null) return;
                        // found new vertex, so recur
                    else if (!marked[w]) {
                        edgeTo[w] = v;
                        dfs(G, w);
                    }
                    // trace back directed cycle
                    else if (onStack[w]) {
                        cycle = new Stack<Integer>();
                        for (int x = v; x != w; x = edgeTo[x]) {
                            cycle.push(x);
                        }
                        cycle.push(w);
                        cycle.push(v);
                        assert check();
                    }
                }
                onStack[v] = false;
            }

            public boolean hasCycle() {
                return cycle != null;
            }

            public Iterable<Integer> cycle() {
                return cycle;
            }

            private boolean check() {
                if (hasCycle()) {
                    // verify cycle
                    int first = -1, last = -1;
                    for (int v : cycle()) {
                        if (first == -1) first = v;
                        last = v;
                    }
                    if (first != last) {
                        System.err.printf("cycle begins with %d and ends with %d\n", first, last);
                        return false;
                    }
                }
                return true;
            }
        }
    }
    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
    }
    static class IOUtils {
        public static void readIntArrays(InputReader in, int[]... arrays) {
            for (int i = 0; i < arrays[0].length; i++) {
                for (int j = 0; j < arrays.length; j++) {
                    arrays[j][i] = in.readInt();
                }
            }
        }
    }
    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0) {
                    writer.print(' ');
                }
                writer.print(objects[i]);
            }
        }

        public void printLine(Object... objects) {
            print(objects);
            writer.println();
        }

        public void close() {
            writer.close();
        }
    }
    static class MiscUtils {
        public static void decreaseByOne(int[]... arrays) {
            for (int[] array : arrays) {
                for (int i = 0; i < array.length; i++) {
                    array[i]--;
                }
            }
        }
    }
}

