#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<malloc.h>
int i,j,k,l,m,n,x,y,swi;
int a[150][150],vis[150];
int dfs(int v){
int i=1;
vis[v] = -1;
for(i = 1; i <= n; i++)
{
if(a[v][i] != 0 && !vis[i]) {
dfs(i);
vis[i]=1;
}
if(a[v][i] != 0 && vis[i] == -1){
printf("NO\n");
swi=1;
return 0;
}
}
return 0;
}
int main ()
{
while (scanf("%d %d",&n,&m)!=EOF)
{
memset(a,0,sizeof(a));
memset(vis,0,sizeof(vis));
swi=0;
for (i=1;i<=m;i++)
{
scanf("%d %d",&x,&y);
if (x!=y) a[x][y]=1;
}
dfs(1);
if(!swi) printf("YES\n");
}
return 0;
}