#include <iostream>
#include <vector>
#include <stack>
#include <map>

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define vi vector<int>
#define pb push_back

int unused_from, unused_to;


#define MAX_V 100000
vector<int> G[MAX_V];
vector<int> Grev[MAX_V];
bool used[MAX_V]={};
int ord[MAX_V],lowlink[MAX_V];
int k=0;

void dfs(int v,int prev){   //make ord and lowlink
    used[v] = true;
    ord[v]=lowlink[v]=k;
    k++;
    
    rep(i,Grev[v].size()){
        int to = Grev[v][i];
        if((v==unused_from&&to==unused_to)||(v==unused_to&&to==unused_from))continue;
        if(!used[to]){
            dfs(to,v);
            lowlink[v] = min(lowlink[v],lowlink[to]);
        }
        else if(used[to]&&to!=prev){    //use back edge
            lowlink[v] = min(lowlink[v],ord[to]);
        }
    }
}

vector<pii> enumerateBridge(int e,vector<pii> edges){   //????????????
    vector<pii> ret;
    
    rep(i,e){
        int a = edges[i].first, b = edges[i].second;
        if((a==unused_from&&b==unused_to)||(a==unused_to&&b==unused_from))continue;
        if(ord[a]>ord[b])swap(a,b);
        if(ord[a]<lowlink[b])ret.pb(pii(edges[i].first,edges[i].second));
    }
    return ret;
}



bool hasLoop(int v){
    vector<int> in_deg(v,0);
    rep(i,MAX_V){
        rep(j,G[i].size()){
            int from = i, to = G[i][j];
            if(from==unused_from&&to==unused_to)continue;
            in_deg[to]++;
        }
    }
    
    stack<int> st;
    vector<int> list;
    
    rep(i,v)if(in_deg[i]==0)st.push(i);
    
    while(st.size()){
        int q = st.top();
        st.pop();
        list.pb(q);
        
        rep(i,G[q].size()){
            int to = G[q][i];
            if(q==unused_from&&to==unused_to)continue;
            in_deg[to]--;
            if(in_deg[to]==0)st.push(to);
        }
    }
    
    if(list.size()!=v)return true;
    return false;
    
}


int main(){
    int v,e;
    cin>>v>>e;
    vector<pii> edges;
    
    rep(i,e){
        int a,b;
        cin>>a>>b;
        a--,b--;
        edges.pb(pii(a,b));
        G[a].pb(b);
        Grev[a].pb(b),Grev[b].pb(a);
    }
    
    
    dfs(0,-1);
    vector<pii> bridge_list = enumerateBridge(e,edges);
    map<pii,bool> mp;
    rep(i,bridge_list.size())mp[bridge_list[i]]=true;
    
    
    rep(i,MAX_V){
        rep(j,G[i].size()){
            unused_from = i;
            unused_to = G[i][j];
            
            rep(i,MAX_V)used[i]=false;
            k=0;
            dfs(0,-1);
            vector<pii> brg = enumerateBridge(e,edges);
            
            if( not mp[pii(unused_from,unused_to)] && brg.size()>=2 && not hasLoop(v)){
                //                cout<<unused_from+1<<" "<<unused_to+1<<endl;  //1????????????????????????????????????
                cout<<"YES"<<endl;
                return 0;
            }
        }
    }
    cout<<"NO"<<endl;
}