local n,m=io.read("n","n")
local box={}
local red={}
for i=1,n do
    box[i]=1
    red[i]=false
end
red[1]=true

for i=1,m do
    local x,y=io.read("n","n")
    if red[x] then
        red[y]=true
    end
    box[x]=box[x]-1
    box[y]=box[y]+1
    if box[x]==0 then
        red[x]=false
    end
end

local counter=0
for i=1,n do
    counter=counter+(red[i] and 1 or 0)
end
print(counter)