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

int N, M;
int k[100000];
bool red[100000];
int res;

int main() {
  cin >> N >> M;
  for(int i = 0; i < N; ++i) k[i] = 1;
  red[0] = true;
  for(int i = 0; i < M; ++i) {
    int X, Y; cin >> X >> Y; --X; --Y;
    --k[X]; ++k[Y];
    if(red[X]) red[Y] = true;
    if(k[X] == 0) red[X] = false;
  }
  for(int i = 0; i < N; ++i) res += red[i];
  cout << res << endl;
  return 0;
}
