1 #include<cstdio>
2 #include<cstdlib>
3 #include<cmath>
4 #include<cstring>
5 #include<algorithm>
6 #include<iostream>
7 #include<vector>
8 #include<map>
9 #include<set>
10 #include<queue>
11 #define inf 1000000000
12 #define maxn 110
13 #define maxm 500+100
14 #define eps 1e-10
15 #define ll long long
16 #define pa pair<int,int>
17 using namespace std;
18 inline int read()
19 {
20 int x=0,f=1;char ch=getchar();
21 while(ch<‘0‘||ch>‘9‘){if(ch==‘-‘)f=-1;ch=getchar();}
22 while(ch>=‘0‘&&ch<=‘9‘){x=10*x+ch-‘0‘;ch=getchar();}
23 return x*f;
24 }
25 int p[maxn],n,m,f[maxn][maxn];
26 bool v[maxn];
27 bool find(int x)
28 {
29 for(int i=1;i<=n;i++)
30 if (f[x][i])
31 if(!v[i])
32 {
33 v[i]=1;
34 if(!p[i]||find(p[i]))
35 {
36 p[i]=x;
37 return 1;
38 }
39 }
40 return 0;
41 }
42 int main()
43 {
44 freopen("input.txt","r",stdin);
45 freopen("output.txt","w",stdout);
46 n=read();m=read();
47 int x,y;
48 while(m--)x=read(),y=read(),f[x][y]=1;
49 for(int k=1;k<=n;k++)
50 for(int i=1;i<=n;i++)
51 for(int j=1;j<=n;j++)
52 f[i][j]=f[i][j]||(f[i][k]&&f[k][j]);
53 int ans=0;
54 for(int i=1;i<=n;i++)
55 {
56 memset(v,0,sizeof(v));
57 if(find(i))ans++;
58 }
59 printf("%d\n",n-ans);
60 return 0;
61 }