#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
typedef pair<int,int> PII;
const int N = 100010;
int n,k;
int st[N];
int main()
{
cin>>n>>k;
int x,y;
int res = 0;
st[0] = 1;
for(int i = 1; i<=k; i++)
{
cin>>x>>y;
if(st[y] == 0)
{
res++;
//cout<<i<<' ';
}
st[x] = 1;
}
cout<<res;
return 0;
}