#include <algorithm>
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;

int main() {
    int n, m; cin >> n >> m;
    vector<int> cnt(n, 1), red(n, false);
    red[0] = true;
    while (m--) {
        int s, t; cin >> s >> t; s--, t--;
        red[t] |= red[s], cnt[t]++;
        if (--cnt[s] == 0) red[s] = 0;
    }
    cout << accumulate(begin(red), end(red), 0) << endl;
    return 0;
}
