#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

bool topologicalSort(const vector<vector<int> >& edges, vector<int>& node)
{
    int n = edges.size();
    node.resize(n);

    vector<int> restEdges(n, 0);
    for(int i=0; i<n; ++i){
        for(unsigned j=0; j<edges[i].size(); ++j){
            ++ restEdges[edges[i][j]];
        }
    }

    int restNodes = n;
    queue<int> q;
    for(int i=0; i<n; ++i){
        if(restEdges[i] == 0){
            node[n-restNodes] = i;
            q.push(i);
            -- restNodes;
        }
    }

    while(restNodes > 0){
        if(q.empty()){
            node.clear();
            return false;
        }
        int i = q.front();
        q.pop();

        for(unsigned j=0; j<edges[i].size(); ++j){
            int k = edges[i][j];
            -- restEdges[k];
            if(restEdges[k] == 0){
                node[n-restNodes] = k;
                q.push(k);
                -- restNodes;
            }
        }
    }

    return true;
}

bool isBridge(const vector<vector<int> >& edges, int a, int b)
{
    int n = edges.size();
    queue<int> q;
    vector<bool> check(n, false);
    q.push(a);
    check[a] = true;
    while(!q.empty()){
        int x = q.front();
        q.pop();
        for(int y : edges[x]){
            if(!(x == a && y == b) && !check[y]){
                q.push(y);
                check[y] = true;
            }
        }
    }
    return !check[b];
}

void bridgeDecomposition(const vector<vector<int> >& edges, vector<int>& indexConvert,
                         vector<vector<int> >& nodesOut, vector<vector<int> >& edgesOut)
{
    const int n = edges.size();
    vector<int> num(n, -1), low(n, -1);
    vector<bool> isStk(n, false);
    stack<int> stk;
    int cnt = -1;
    nodesOut.clear();

    for(int i=0; i<n; ++i){
        stack<tuple<int, int, unsigned> > arg;
        arg.push(make_tuple(i, -1, 0));

        while(!arg.empty()){
            int v      = get<0>(arg.top());
            int prev   = get<1>(arg.top());
            unsigned j = get<2>(arg.top());
            arg.pop();

            if(j == 0){
                if(num[v] != -1)
                    continue;
                num[v] = low[v] = ++ cnt;
                stk.push(v);
                isStk[v] = true;
            }
            else{
                int w = edges[v][j-1];
                if(w != prev && isStk[w])
                    low[v] = min(low[v], low[w]);
            }

            if(j < edges[v].size()){
                arg.push(make_tuple(v, prev, j + 1));
                int w = edges[v][j];
                if(w != prev)
                    arg.push(make_tuple(w, v, 0));
            }
            else if(low[v] == num[v]){
                nodesOut.push_back(vector<int>());
                for(;;){
                    int w = stk.top();
                    stk.pop();
                    isStk[w] = false;
                    nodesOut.back().push_back(w);
                    if(v == w)
                        break;
                }
            }
        }
    }

    const int m = nodesOut.size();
    indexConvert.resize(n);
    for(int i=0; i<m; ++i){
        for(unsigned j=0; j<nodesOut[i].size(); ++j)
            indexConvert[nodesOut[i][j]] = i;
    }
    edgesOut.assign(m, vector<int>());
    vector<set<int> > used(m);
    for(int i=0; i<n; ++i){
        for(unsigned j=0; j<edges[i].size(); ++j){
            int v = indexConvert[i];
            int w = indexConvert[edges[i][j]];
            if(v != w && used[v].find(w) == used[v].end()){
                edgesOut[v].push_back(w);
                used[v].insert(w);
            }
        }
    }
}

int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<int> > edges(n), directedEdges(n);
    for(int i=0; i<m; ++i){
        int a, b;
        cin >> a >> b;
        -- a;
        -- b;
        edges[a].push_back(b);
        edges[b].push_back(a);
        directedEdges[a].push_back(b);
    }

    for(int a=0; a<n; ++a){
        for(unsigned i=0; i<directedEdges[a].size(); ++i){
            int b = directedEdges[a][i];
            if(isBridge(edges, a, b))
                continue;

            vector<vector<int> > directEdges2 = directedEdges;
            directEdges2[a].erase(find(directEdges2[a].begin(), directEdges2[a].end(), b));
            vector<int> tmp;
            if(!topologicalSort(directEdges2, tmp))
                continue;

            vector<vector<int> > edges2 = edges;
            edges2[a].erase(find(edges2[a].begin(), edges2[a].end(), b));
            edges2[b].erase(find(edges2[b].begin(), edges2[b].end(), a));
            vector<int> tmp1;
            vector<vector<int> > nodes, tmp2;
            bridgeDecomposition(edges2, tmp1, nodes, tmp2);

            if(nodes.size() >= 3){
                cout << "YES" << endl;
                return 0;
            }
        }
    }

    cout << "NO" << endl;
    return 0;
}