#include<bits/stdc++.h>
using namespace std;
#define MAX_N 500
#define MAX_M 30000
struct edge{ int from,to,id; };
int N,M;
int a[MAX_M],b[MAX_M];
vector<edge> G[MAX_N];

bool visited[MAX_N];
int depth[MAX_N];
int cnt[MAX_N];
vector<edge> bridges;

void dfs(int pos,int prev){
  visited[pos]=true;
  for(int i=0;i<(int)G[pos].size();i++){
    int to=G[pos][i].to;
    if(to==prev)continue;
    if(!visited[to]){
      depth[to]=depth[pos]+1;
      dfs(to,pos);
      cnt[pos]+=cnt[to];
      if(cnt[to]==0)bridges.push_back(G[pos][i]);
    }else if(depth[to]<depth[pos]){
      cnt[pos]++;
      cnt[to]--;
    }
  }
}

int countB(int id){
  bridges.clear();
  memset(visited,false,sizeof(visited));
  memset(depth,0,sizeof(depth));
  memset(cnt,0,sizeof(cnt));
  for(int i=0;i<N;i++)G[i].clear();
  for(int i=0;i<M;i++){
    if(i==id)continue;
    G[ a[i] ].push_back( (edge){ a[i],b[i],i } );
    G[ b[i] ].push_back( (edge){ b[i],a[i],i } );
  }
  for(int i=0;i<N;i++){
    if(visited[i])continue;
    dfs(i,-1);
  }
  return bridges.size();
}

bool check(int id){
  int B=countB(id);

  memset(visited,false,sizeof(visited));
  int U=0;
  for(int i=0;i<N;i++)
    if(!visited[i])U++,dfs(i,-1);
  
  if(B+U<3)return false;
  
  queue<int> Q;
  vector<int> C(N,0);
  for(int i=0;i<M;i++)
    if(id!=i)C[ b[i] ]++;
  for(int i=0;i<N;i++)
    if(C[i]==0)Q.push(i);
  int cc=0;
  while(!Q.empty()){
    int pos=Q.front();Q.pop();
    cc++;
    for(int i=0;i<(int)G[pos].size();i++){
      int to=G[pos][i].to;
      C[to]--;
      if(C[to]==0)Q.push(to);
    }
  }
  if(cc==N)return true;
  else return false;
}

vector<edge> loope;
bool rec(int pos,int si,int pre=-1){
  if(visited[pos])return (pos==si);
  visited[pos]=true;
  for(int i=0;i<(int)G[pos].size();i++){
    edge e=G[pos][i];
    if(e.id==pre)continue;
    
    if( rec(e.to,si,e.id) ){
      loope.push_back(e);
      return true;
    }
  }
  return false;
}

bool solve2(){

  for(int i=0;i<M;i++){
    if(check(i))return true;
  }
  
  for(int i=0;i<N;i++){
    memset(visited,false,sizeof(visited));
    memset(depth,0,sizeof(depth));
    loope.clear();
    if( rec(i,i) ){
      break;
    }
  }
  for(int i=0;i<(int)loope.size();i++){
    if(check( loope[i].id ))return true;
  }
  return false;
}

bool solve(){
  if(countB(-1)==M)return false;
  
  for(int i=0;i<N;i++)G[i].clear();
  for(int i=0;i<M;i++)G[ a[i] ].push_back( (edge){a[i],b[i],i} );
  if(solve2())return true;
  
  for(int i=0;i<N;i++)G[i].clear();
  for(int i=0;i<M;i++)G[ a[i] ].push_back( (edge){a[i],b[i],i} );
  for(int i=0;i<M;i++)G[ b[i] ].push_back( (edge){b[i],a[i],i} );
  if(solve2())return true;  
  return false;
}

int main(){
  cin>>N>>M;
  for(int i=0;i<M;i++){
    cin>>a[i]>>b[i];
    a[i]--;
    b[i]--;
  }
  cout<< ( solve() ? "YES" : "NO" ) <<endl;
  return 0;
}