#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 1e5+10;
int a[N]={1};
int n,k,x,y,res;
int main()
{
cin>>n>>k;
while(k--){
cin>>x>>y;
if(!a[y]) res++;
a[x]++;
}
cout << res;
return 0;
}