#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

class SCC{
    using VI=vector<int>;
    using VVI=vector<VI>;
    using EDGE=VVI;
private:
    EDGE e,r_e;
    VI vs;
public:
    int size;
    VI comp;
    VVI nodeset;
    EDGE newedge;
private:
    void dfs(int v){
        comp[v]=0;
        for(auto&u:e[v])if(comp[u]==-1)dfs(u);
        vs.push_back(v);
    }
    void rdfs(int v,int k){
        comp[v]=k;
        for(auto&u:r_e[v])if(comp[u]==-1)rdfs(u,k);
    }
    void decomposition(){
        comp.resize(size);
        fill(comp.begin(),comp.end(),-1);
        vs.clear();
        for(int v=0;v<size;v++)if(comp[v]==-1)dfs(v);
        reverse(vs.begin(),vs.end());
        fill(comp.begin(),comp.end(),-1);
        int k=0;
        for(auto&v:vs)if(comp[v]==-1)rdfs(v,k++);
        nodeset.resize(k);
        newedge.resize(k);
        for(int v=0;v<size;v++){
            nodeset[comp[v]].push_back(v);
            for(auto&u:e[v])
                if(!isSameComponents(v,u))
                    newedge[comp[v]].push_back(comp[u]);
        }
        size=k;
    }
public:
    bool isSameComponents(int a,int b){return comp[a]==comp[b];}

};

#define REP(i, n) for(ll i = 0; i < (n); ++i)

bool check(vector<vector<pair<ll,ll>>>&paths,int n,int m, int unused ){
    vector<ll> visited(n, 0);
    function<bool(ll)> dfs = [&](ll cur){
        if (visited[cur] == 1) return true;
        if(visited[cur] == 2) return false;
        visited[cur] = 1;
        for (auto next : paths[cur]) if(next.second != unused) {
            if(dfs(next.first)) return true;
        }
        visited[cur] = 2;
        return false;
    };

    REP(i, n) if(visited[i] == 0){
        if(dfs(i)) return false;
    }
    return true;
}
typedef vector<ll> E;
typedef vector<E> Graph;
int connected(Graph &g){
    int n=g.size();
    vector<int> used(n,0);
    used[0]=1;
    queue<int> que;
    que.push(0);
    while(que.size()){
        auto v=que.front();que.pop();
        for(auto &u:g[v]){
            if(used[u]==0){
                que.push(u);
                used[u]=1;
            }
        }
    }
    int f=1;
    for(auto &it:used)
        f&=it;
    return f;

}

void dfs(Graph &g,int v,int p,E& imos,E& used,E&depth){
    depth[v]=depth[p]+1;
    used[v]=1;
    for(auto &u:g[v])
        if(p!=u){
            if(used[u]){
                if(depth[v]>depth[u]){
                    imos[v]++;
                    imos[u]--;
                    //   cout<<"   "<<u+1<<endl;
                }
            }
            else{
                dfs(g,u,v,imos,used,depth);
            }
        }

    //cout<<v<<" "<<p<<endl;
}
int dfs2(Graph &g,int v,int p,E& imos,E& used){
    used[v]=0;
    int res=0;
    for(auto &u:g[v])
        if(p!=u){
            if(used[u]){
                res+=dfs2(g,u,v,imos,used);
                imos[v]+=imos[u];
            }
        }
    // cout<<v<<" "<<imos[v]<<endl;
    if(imos[v]==0)res++;
    return res;
}

int main(){
    ll n,m;
    cin >> n>> m;
    vector<vector<pair<ll,ll>>> paths(n);
    REP(i, m){
        ll a,b;
        cin>>a>>b;
        a--,b--;
        paths[a].push_back({b, i});
    }

    REP(i, m){
        if(!check(paths, n, m, i)) continue;
        vector<vector<ll> > g(n);
        REP(j, n){
            for(auto next : paths[j]) {
                if(next.second != i) {
                    g[j].push_back(next.first);
                    g[next.first].push_back(j);
                }
            }
        }

        if(!connected(g))continue;
        E imos(n,0);
        E used(n,0);

        E depth(n,0);
        imos[0]=1;
        dfs(g,0,0,imos,used,depth);
        int res=dfs2(g,0,0,imos,used);
        if(res>=2){
            // cout<<i<<endl<<res<<endl;
            cout<<"YES"<<endl;
            return 0;
        }
    }


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

Measured memory_bytes: 3164