program main
  implicit none
  integer::n,m,x,y,i
  integer,allocatable::a(:),c(:)
  read*,n,m
  allocate(a(n),c(n))
  a(:)=0
  a(1)=1
  c(:)=1
  do i=1,m
     read*,x,y
     if (a(x).eq.0)then
        if(c(x).ne.0)then
           c(x)=c(x)-1
           c(y)=c(y)+1
        endif
     else
        if(c(x).lt.2)a(x)=0
        c(x)=c(x)-1
        a(y)=1
        c(y)=c(y)+1
     endif
  enddo
  print*,count(a.ne.0)
end program main