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)cycle
     if (c(x).lt.2)a(x)=0
     c(x)=c(x)-1
     a(y)=1
     c(y)=c(y)+1
!     print*,a,c
  enddo
!  print*,a,c
  print*,count(a.ne.0)
end program main