local n, m = io.read("*n", "*n")
local cnt, may = {1}, {true}
for i = 2, n do
  cnt[i] = 1
  may[i] = false
end
for i = 1, m do
  local x, y = io.read("*n", "*n")
  if may[x] then may[y] = true end
  cnt[x], cnt[y] = cnt[x] - 1, cnt[y] + 1
  if cnt[x] == 0 then may[x] = false end
end
local ret = 0
for i = 1, n do
  if may[i] then ret = ret + 1 end
end
print(ret)
