#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1e5 + 2;
int n, m, num[MAXN];
bool red[MAXN];

int main()
{
    cin >> n >> m;
    fill(num + 1, num + n + 1, 1);
    red[1] = true;
    for(int i = 0;i < m;i++)
    {
        int x, y;
        cin >> x >> y;
        num[x]--;
        num[y]++;
        if(red[x] == true)red[y] = true;
        if(num[x] == 0)red[x] = false;
    }
    int ans = 0;
    for(int i = 1;i <= n;i++)
        ans += red[i];
    cout << ans << '\n';
    return 0;
}
