{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"In the animal kingdom, there are three types of animals A, B, and C, and the food chain of these three types of animals forms an interesting cycle. A eats B, B eats C, and C eats A.\n\u003cbr\u003eThere are N animals, numbered from 1 to N. Each animal is one of A, B, or C, but we do not know which type it is.\n\u003cbr\u003eSomeone describes the food chain relationship of these N animals in two ways:\n\u003cbr\u003eThe first way is \"1 X Y\", which means X and Y are of the same type.\n\u003cbr\u003eThe second way is \"2 X Y\", which means X eats Y.\n\u003cbr\u003eThis person describes the relationships of the N animals using the above two ways, one sentence after another, with some sentences being true and some being false. A sentence is considered false if it meets one of the following three conditions:\n\u003cbr\u003e1) The current sentence conflicts with some true sentences before it;\n\u003cbr\u003e2) X or Y in the current sentence is greater than N;\n\u003cbr\u003e3) The current sentence indicates that X eats X.\n\u003cbr\u003eYour task is to output the total number of false sentences based on the given N (1 \u0026lt;\u003d N \u0026lt;\u003d 50,000) and K sentences (0 \u0026lt;\u003d K \u0026lt;\u003d 100,000)."}},{"title":"Input","value":{"format":"HTML","content":"The first line contains two integers N and K, separated by a space.\n\u003cbr\u003eEach of the following K lines contains three positive integers D, X, Y, separated by a space, where D represents the type of statement.\n\u003cbr\u003e If D\u003d1, it means X and Y are of the same type.\n\u003cbr\u003e If D\u003d2, it means X eats Y."}},{"title":"Output","value":{"format":"HTML","content":"A single integer, representing the number of false statements."}},{"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\u003e100 7\r\n1 101 1 \r\n2 1 2\r\n2 2 3 \r\n2 3 3 \r\n1 1 3 \r\n2 3 1 \r\n1 5 5\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e3\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e"}}]}