#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"i=lambda:map(int,input().split());n,m=i();a=[0]+[1]*n;b=[0,1]+[0]*n\n"
"for _ in[0]*m:x,y=i();a[x]-=1;a[y]+=1;b[y]|=b[x];b[x]&=a[x]>0\n"
"print(sum(b))\n"
"\"";
  system(s);
  return 0;
}            