#include <stdio.h> #include <string.h> #define Max 300 #define INF 5000000 int flow[Max][Max],d[Max]; int map[Max][Max]; int sta,end; int m,n; int min(int a,int b) { if(a<b) return a; else return b; } bool bfs(int s) { int front=0,rear=0; int q[Max*100]; int k,i; memset(d,-1,sizeof(d)); q[rear++]=s; d[s]=0; while(front<rear) { k=q[front++]; if(k==end) break; for(i=1;i<=2*n;i++) if(flow[k][i]>0&&d[i]==-1) { d[i]=d[k]+1; q[rear++]=i; } } if(d[end]>=0) return true; return false; } int dinic(int k,int sum) { int i,a; if(k==end) return sum; int os=sum; for(i=1;i<=2*n&∑i++) if(d[i]==d[k]+1&&flow[k][i]>0) { a=dinic(i,min(sum,flow[k][i])); flow[k][i]-=a; flow[i][k]+=a; sum-=a; } return os-sum; } int main() { int x,y; while(scanf("%d%d",&n,&m)!=EOF) { memset(map,0,sizeof(map)); int i,j,k; for(i=1;i<=n;i++) map[i][i+n]=1; for(i=1;i<=m;i++) { scanf(" (%d,%d)",&x,&y); x++;y++; map[y+n][x]=INF; map[x+n][y]=INF; } int ans=INF; int now; sta=n+1; for(i=2;i<=n;i++) { for(k=1; k <= 2*n; k++) for(j=1; j <= 2*n; j++) flow[k][j]=map[k][j]; end=i; now=0; while(bfs(sta)) now+=dinic(sta,INF); if(now<ans) ans=now; } if(ans>=INF) printf("%d ",n); else printf("%d ",ans); } return 0; }