#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<int> r(n+1,0);
    r[1] = 1;
    vector<int> w(n+1,1);
    w[1] = 0;
    for(int i = 0; i < m; i++){
        int x, y;
        cin >> x >> y;
        if(r[x]){
            r[x]--;
            r[y]++;
            if(w[y]){
                r[y] += w[y];
                w[y] = 0;
            }
        }
        else{
            w[x]--;
            w[y]++;
        }
    }
    int ans = 0;
    for(int i = 1; i < n+1; i++)
        if(r[i])ans++;
    cout << ans << endl;
    return 0;
}
