{"trustable":false,"sections":[{"title":"","value":{"format":"HTML","content":"Have you ever read any book about treasure exploration? Have you ever see any film about treasure exploration? Have you ever explored treasure? If you never have such experiences, you would never know what fun treasure exploring brings to you.\n\u003cbr\u003eRecently, a company named EUC (Exploring the Unknown Company) plan to explore an unknown place on Mars, which is considered full of treasure. For fast development of technology and bad environment for human beings, EUC sends some robots to explore the treasure.\n\u003cbr\u003eTo make it easy, we use a graph, which is formed by N points (these N points are numbered from 1 to N), to represent the places to be explored. And some points are connected by one-way road, which means that, through the road, a robot can only move from one end to the other end, but cannot move back. For some unknown reasons, there is no circle in this graph. The robots can be sent to any point from Earth by rockets. After landing, the robot can visit some points through the roads, and it can choose some points, which are on its roads, to explore. You should notice that the roads of two different robots may contain some same point. \n\u003cbr\u003eFor financial reason, EUC wants to use minimal number of robots to explore all the points on Mars.\n\u003cbr\u003eAs an ICPCer, who has excellent programming skill, can your help EUC?\n\u003cbr\u003e给定一个有向图,可以在任意一个点上放置一个机器人,每个机器人可以沿一条有向简单路径移动,求使得所有节点都至少被一条路径经过需要的最少机器人数量。"}},{"title":"Input","value":{"format":"HTML","content":"The input will consist of several test cases. For each test case, two integers N (1 \u0026lt;\u003d N \u0026lt;\u003d 500) and M (0 \u0026lt;\u003d M \u0026lt;\u003d 5000) are given in the first line, indicating the number of points and the number of one-way roads in the graph respectively. Each of the following M lines contains two different integers A and B, indicating there is a one-way from A to B (0 \u0026lt; A, B \u0026lt;\u003d N). The input is terminated by a single line with two zeros."}},{"title":"Output","value":{"format":"HTML","content":"For each test of the input, print a line containing the least robots needed."}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e1 0\n2 1\n1 2\n2 0\n0 0\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e1\n1\n2\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}