/****************************************************************************************************** ** Copyright (C) 2011.07.01-2013.07.01 ** Author: famousDT <[email protected]> ** Edit date: 2011-10-03 ******************************************************************************************************/ #include <stdio.h> #include <stdlib.h>//abs,atof(string to float),atoi,atol,atoll #include <math.h>//atan,acos,asin,atan2(a,b)(a/b atan),ceil,floor,cos,exp(x)(e^x),fabs,log(for E),log10 #include <vector> #include <queue> #include <map> #include <time.h> #include <set> #include <stack> #include <string> #include <iostream> #include <assert.h> #include <string.h>//memcpy(to,from,count #include <ctype.h>//character process:isalpha,isdigit,islower,tolower,isblank,iscntrl,isprll #include <algorithm> using namespace std; //typedef long long ll; #define MY_PI acos(-1) #define MY_MAX(a, b) ((a) > (b) ? (a) : (b)) #define MY_MIN(a, b) ((a) < (b) ? (a) : (b)) #define MY_MALLOC(n, type) ((type *)malloc((n) * sizeof(type))) #define MY_ABS(a) (((a) >= 0) ? (a) : (-(a))) #define MY_INT_MAX 0x7fffffff /*==========================================================*\ | max(出度为0的点的个数,入度为0的点的个数)就是此题的答案 | http://hi.baidu.com/c%C3%D42/blog/item/f5efe0a844749daaca130c32.html \*==========================================================*/ struct my { int a, b; }wo[100 + 1]; int main() { int m, n; int i; int x, y; while (scanf("%d%d", &m, &n) == 2) { for (i = 0; i <= m; ++i) wo[i].a = wo[i].b = 0; for (i = 0; i < n; ++i) { scanf("%d%d", &x, &y); wo[x].b++; wo[y].a++; } int maxa = 0, maxb = 0; for (i = 1; i <= m; ++i) { if (wo[i].a == 0) maxa++; if (wo[i].b == 0) ++maxb; } printf("%d\n", MY_MAX(maxa, maxb)); } return 0; }