import sys

stdin = sys.stdin

 

sys.setrecursionlimit(10**5) 

 

def li(): return list(map(int, stdin.readline().split()))

def li_(): return [int(x)-1 for x in stdin.readline().split()]

def lf(): return list(map(float, stdin.readline().split()))

def ls(): return stdin.readline().split()

def ns(): return stdin.readline().rstrip()

def lc(): return list(ns())

def ni(): return int(stdin.readline())

def nf(): return float(stdin.readline())



def operation(box:list, frm:int, to:int):

    box[frm] -= 1

    box[to] += 1

    

n,m = li()

box = [1 for _ in range(n)]

cand = [False for _ in range(n)]

cand[0] = True

ope = []

for _ in range(m):

    x,y = li_()

    ope.append((x,y))

    

for x,y in ope:

    operation(box,x,y)

    if (not cand[y]) and cand[x]:

        cand[y] = True

    

    if cand[x] and box[x] > 0:

        cand[x] = True

        

    elif cand[x] and box[x] == 0:

        cand[x] = False

        

print((sum(cand)))
import sys

stdin = sys.stdin

 

sys.setrecursionlimit(10**8) 

 

def li(): return list(map(int, stdin.readline().split()))

def li_(): return [int(x)-1 for x in stdin.readline().split()]

def lf(): return list(map(float, stdin.readline().split()))

def ls(): return stdin.readline().split()

def ns(): return stdin.readline().rstrip()

def lc(): return list(ns())

def ni(): return int(stdin.readline())

def nf(): return float(stdin.readline())



n,m = li()

ball = [1]*n

inred = [0]*n

inred[0] = 1



for _ in range(m):

    x,y = li_()

    if inred[x] and ball[x] == 1:

        inred[x] = 0

        ball[x] = 0

        

        inred[y] = 1

        ball[y] += 1

        

    elif inred[x] and ball[x] > 1:

        ball[x] -= 1

        

        inred[y] = 1

        ball[y] += 1

        

    else:

        ball[x] -= 1

        ball[y] += 1

        

ans = 0

for ri in inred:

    ans += ri

print(ans)
import sys

stdin = sys.stdin
sys.setrecursionlimit(10**5)


def li():
    return list(map(int, stdin.readline().split()))


def li_():
    return [int(x) - 1 for x in stdin.readline().split()]


def lf():
    return list(map(float, stdin.readline().split()))


def ls():
    return stdin.readline().split()


def ns():
    return stdin.readline().rstrip()


def lc():
    return list(ns())


def ni():
    return int(stdin.readline())


def nf():
    return float(stdin.readline())


def operation(box: list, frm: int, to: int):
    box[frm] -= 1
    box[to] += 1


n, m = li()
box = [1 for _ in range(n)]
cand = [False for _ in range(n)]
cand[0] = True
ope = []
for _ in range(m):
    x, y = li_()
    ope.append((x, y))
for x, y in ope:
    operation(box, x, y)
    if (not cand[y]) and cand[x]:
        cand[y] = True
    if cand[x] and box[x] > 0:
        cand[x] = True
    elif cand[x] and box[x] == 0:
        cand[x] = False
print((sum(cand)))

import sys

stdin = sys.stdin
sys.setrecursionlimit(10**8)


def li():
    return list(map(int, stdin.readline().split()))


def li_():
    return [int(x) - 1 for x in stdin.readline().split()]


def lf():
    return list(map(float, stdin.readline().split()))


def ls():
    return stdin.readline().split()


def ns():
    return stdin.readline().rstrip()


def lc():
    return list(ns())


def ni():
    return int(stdin.readline())


def nf():
    return float(stdin.readline())


n, m = li()
ball = [1] * n
inred = [0] * n
inred[0] = 1
for _ in range(m):
    x, y = li_()
    if inred[x] and ball[x] == 1:
        inred[x] = 0
        ball[x] = 0
        inred[y] = 1
        ball[y] += 1
    elif inred[x] and ball[x] > 1:
        ball[x] -= 1
        inred[y] = 1
        ball[y] += 1
    else:
        ball[x] -= 1
        ball[y] += 1
ans = 0
for ri in inred:
    ans += ri
print(ans)

-sys.setrecursionlimit(10**5) +sys.setrecursionlimit(10**8) -def operation(box: list, frm: int, to: int): -    box[frm] -= 1 -    box[to] += 1 - - -box = [1 for _ in range(n)] -cand = [False for _ in range(n)] -cand[0] = True -ope = [] +ball = [1] * n +inred = [0] * n +inred[0] = 1 -    ope.append((x, y)) -for x, y in ope: -    operation(box, x, y) -    if (not cand[y]) and cand[x]: -        cand[y] = True -    if cand[x] and box[x] > 0: -        cand[x] = True -    elif cand[x] and box[x] == 0: -        cand[x] = False -print((sum(cand))) +    if inred[x] and ball[x] == 1: +        inred[x] = 0 +        ball[x] = 0 +        inred[y] = 1 +        ball[y] += 1 +    elif inred[x] and ball[x] > 1: +        ball[x] -= 1 +        inred[y] = 1 +        ball[y] += 1 +    else: +        ball[x] -= 1 +        ball[y] += 1 +ans = 0 +for ri in inred: +    ans += ri +print(ans)