#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int n, m, a[N], b[N];
int main() {
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; i++) a[i] = 1;
    b[1] = 1;
    while (m--) {
        int x, y;
        scanf("%d%d", &x, &y);
        a[x] = max(a[x] - 1, 0);
        a[y]++;
        if (b[x]) {
            b[y] = 1;
            if (!a[x]) b[x] = 0;
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++)
        if (b[i]) ans++;
    printf("%d\n", ans);
    return 0;
}