
#include <iostream>
#include <cstdio>
using namespace std;

int num[100001];//the amount of water in the cup i
bool red[100001];//the cup i contains red water or not
int n, m;
int x, y, ans;
int main() {

    scanf("%d %d", &n, &m);
    for (int i = 1; i <= n; i++) {
            num[i] = 1;
            red[i] = false;
    }
    red[1] = true;

    for (int i = 1; i <=m; i++) {
        scanf("%d %d", &x, &y);
        if (red[x] == true)
            red[y] = true;

        num[x]--;
        num[y]++;

        if (num[x] == 0)
            red[x] = false;
    }

    for (int i = 1; i <=n; i++)
        if (red[i])
            ans++;
    cout << ans << endl;


    return 0;
}
