#include <iostream>
#include <bits/stdc++.h>
#define endl '\n'
#define MAXN 1000010
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pii>
using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    unsigned int n, m; cin >> n >> m;
    vi r(n), balls(n, 1);
    r[0] = 1;
    int temp = m;
    while (temp--) {
        int c1, c2; cin >> c1 >> c2;
        c1--;
        c2--;
        if(balls[c1] > 1 || r[c1]){
            r[c2] = 1;
            if(balls[c1] == 1) r[c1] = 0;
        }
        else if(balls[c1] == 1 && r[c1]){
            r[c1] = 0;
            r[c2] = 1;
        }
        --balls[c1];
        ++balls[c2];
    }
    int count = 0;
    for (int i = 0; i < n; ++i) {
        if(r[i]) ++count;
    }
    cout << count << endl;
    return 0;
}
