using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

namespace Brown
{
    using static Ex;
    public class Solve
    {
        public static void Main(string[] args)
        {
            new agc002_b();
        }
    }
    public class agc002_b
    {
        public agc002_b()
        {
            var (n, m) = ReadIntArray().ToTpl2();
            var cou = new int[n];
            var red = new bool[n];

            for (int i = 0; i < n; i++)
                cou[i] = 1;
            red[0] = true;
            for (int i = 0; i < m; i++)
            {
                var (x, y) = ReadIntArray().ToTpl2();
                x--;
                y--;
                red[y] |= red[x];
                cou[x]--;
                cou[y]++;
                if (cou[x] == 0)
                    red[x] = false;
            }

            red.Count(v => v).Cw();
        }
    }
    public class abc129_c
    {
        public abc129_c()
        {
            var (n, m) = ReadIntArray().ToTpl2();
            var a = new HashSet<int>(ReadIntArray(m));

            var dp = new ModInt[n + 2];
            dp[0] = 1;
            for (int i = 0; i < n; i++)
            {
                if (!a.Contains(i + 1))
                {
                    dp[i + 1] += dp[i];
                }
                if (!a.Contains(i + 2))
                {
                    dp[i + 2] += dp[i];
                }
            }
            dp[n].Cw();
        }
    }
    public class jsc2019_qual_b
    {
        public jsc2019_qual_b()
        {
            var (n, k) = ReadLongArray().ToTpl2();
            var a = ReadIntArray();

            ModInt ans = 0;
            var all = new ModInt[n];
            var left = new ModInt[n];
            for (int i = 0; i < n; i++)
            {
                var v = a[i];
                for (int j = i - 1; j >= 0; j--)
                {
                    if (v < a[j])
                    {
                        left[i]++;
                    }
                }
                all[i] += left[i];
                for (int j = i + 1; j < n; j++)
                {
                    if (v < a[j])
                    {
                        all[i]++;
                    }
                }
            }
            string.Join(" ", all).Cw();
            string.Join(" ", left).Cw();
            for (int i = 0; i < n; i++)
            {
                ans += left[i];
                ans += (k - 1) * all[i];
            }
            ans.Cw();
        }
    }
    public class abc073_c
    {
        public abc073_c()
        {
            int n = ReadInt;
            var set = new HashSet<long>();
            int ans = 0;
            for (int i = 0; i < n; i++)
            {
                long a = ReadLong;
                if (set.Contains(a))
                {
                    ans--;
                    set.Remove(a);
                }
                else
                {
                    ans++;
                    set.Add(a);
                }
            }
            ans.Cw();
        }
    }
    public class abc144_d
    {
        int a, b, x;
        public abc144_d()
        {
            (a, b, x) = ReadIntArray().ToTpl3();

            int max = a * a * b;

        }
    }
    public class abc061_c
    {
        long n, k, a, b;
        public abc061_c()
        {
            (n, k) = ReadLongArray().ToTpl2();

            var arr = new long[(int)1e5 + 1];

            for (long i = 0; i < n; i++)
            {
                (a, b) = ReadLongArray().ToTpl2();
                arr[a] += b;
            }
            for (long i = 1; i <= (int)1e5; i++)
            {
                arr[i] += arr[i - 1];
                if (arr[i] > k)
                {
                    i.Cw();
                    return;
                }
            }
        }
    }
    public class abc136_d
    {
        public abc136_d()
        {
            var s = Read.ToArray();
            //var s = Read.Select(v => v == 'L' ? -1 : 1).ToArray();
            var arr = new int[s.Length];
        }
    }
    public class abc149_d
    {
        int n, k;
        public abc149_d()
        {
            (n, k) = ReadIntArray().ToTpl2();
            var score = ReadIntArray();
            var t = Read.Select(c =>
            {
                switch (c)
                {
                    case 'r': return 2;
                    case 's': return 0;
                    case 'p': return 1;
                };
                return 0;
            }).ToArray();

            long ans = 0;
            var arr = new int[n];
            for (int i = 0; i < n; i++)
            {
                var c = t[i];
                if (i >= k && (c == arr[i - k]))
                {
                    for (int a = 0; a < 3; a++)
                    {
                        if (a == c) continue;
                        if ((i + k < n) && a == t[i + k]) continue;
                        c = a;
                        break;
                    }
                }
                else
                {
                    ans += score[c];
                }
                arr[i] = c;
            }
            ans.Cw();
        }
    }
    public class abc_
    {
        public abc_()
        {
        }
    }

    public static class Ex
    {
        public static void Cw(this object s) { Console.WriteLine(s); }



        public static bool Mins<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) > 0) { a = b; return true; } return false; }
        public static bool Maxs<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }
        public static void Swap<T>(ref T a, ref T b) { var t = b; b = a; a = t; }
        public static void Swap<T>(List<T> list, int i, int j) { T tmp = list[j]; list[j] = list[i]; list[i] = tmp; }

        public static long Lcm(int x, int y) { return x / Gcd(x, y) * y; }
        public static long Gcd(long m, long n) { if (n == 0) return m; return Gcd(n, m % n); }
        public static List<string> FastSort(this List<string> s) { s.Sort(StringComparer.Ordinal); return s.ToList(); }
        public static void yesno(this bool b) { (b ? "yes" : "no").Cw(); }
        public static void YesNo(this bool b) { (b ? "Yes" : "No").Cw(); }
        public static void YESNO(this bool b) { (b ? "YES" : "NO").Cw(); }

        public static string Read { get { return Console.ReadLine().Trim(); } }
        public static int ReadInt { get { return int.Parse(Read); } }
        public static long ReadLong { get { return long.Parse(Read); } }
        public static double ReadDouble { get { return double.Parse(Read); } }
        public static string[] ReadArray() { return Read.Split(' '); }
        public static int[] ReadIntArray() { return Read.Split(' ').Select(int.Parse).ToArray(); }
        public static long[] ReadLongArray() { return Read.Split(' ').Select(long.Parse).ToArray(); }
        public static string[] ReadArray(long N) { var v = new string[N]; for (long i = 0; i < N; ++i) v[i] = Read; return v; }
        public static int[] ReadIntArray(long N) { var v = new int[N]; for (long i = 0; i < N; ++i) v[i] = ReadInt; return v; }
        public static long[] ReadLongArray(long N) { var v = new long[N]; for (long i = 0; i < N; ++i) v[i] = ReadLong; return v; }

        public static (T, T) ToTpl2<T>(this T[] v) { return (v[0], v[1]); }
        public static (T, T, T) ToTpl3<T>(this T[] v) { return (v[0], v[1], v[2]); }
        public static (T, T, T, T) ToTpl4<T>(this T[] v) { return (v[0], v[1], v[2], v[3]); }
        public static (T, T, T, T, T) ToTpl5<T>(this T[] v) { return (v[0], v[1], v[2], v[3], v[4]); }


        public struct ModInt
        {
            public const int Mod = (int)1e9 + 7;
            const long POSITIVIZER = ((long)Mod) << 31;
            long Data;
            public ModInt(long data) { if ((Data = data % Mod) < 0) Data += Mod; }
            public static implicit operator long(ModInt modInt) => modInt.Data;
            public static implicit operator ModInt(long val) => new ModInt(val);
            public static ModInt operator +(ModInt a, int b) => new ModInt() { Data = (a.Data + b + POSITIVIZER) % Mod };
            public static ModInt operator +(ModInt a, long b) => new ModInt(a.Data + b);
            public static ModInt operator +(ModInt a, ModInt b) { long res = a.Data + b.Data; return new ModInt() { Data = res >= Mod ? res - Mod : res }; }
            public static ModInt operator -(ModInt a, int b) => new ModInt() { Data = (a.Data - b + POSITIVIZER) % Mod };
            public static ModInt operator -(ModInt a, long b) => new ModInt(a.Data - b);
            public static ModInt operator -(ModInt a, ModInt b) { long res = a.Data - b.Data; return new ModInt() { Data = res < 0 ? res + Mod : res }; }
            public static ModInt operator *(ModInt a, int b) => new ModInt(a.Data * b);
            public static ModInt operator *(ModInt a, long b) => a * new ModInt(b);
            public static ModInt operator *(ModInt a, ModInt b) => new ModInt() { Data = a.Data * b.Data % Mod };
            public static ModInt operator /(ModInt a, ModInt b) => new ModInt() { Data = a.Data * GetInverse(b) % Mod };
            public static bool operator ==(ModInt a, ModInt b) => a.Data == b.Data;
            public static bool operator !=(ModInt a, ModInt b) => a.Data != b.Data;
            public override string ToString() => Data.ToString();
            public override bool Equals(object obj) => (ModInt)obj == this;
            public override int GetHashCode() => (int)Data;
            static long GetInverse(long a)
            {
                long div, p = Mod, x1 = 1, y1 = 0, x2 = 0, y2 = 1;
                while (true)
                {
                    if (p == 1) return x2 + Mod; div = a / p; x1 -= x2 * div; y1 -= y2 * div; a %= p;
                    if (a == 1) return x1 + Mod; div = p / a; x2 -= x1 * div; y2 -= y1 * div; p %= a;
                }
            }
        }

    }
}

Measured memory_bytes: 47276