




'''simple docstring'''
import numpy as np
from numpy import floataa
from numpy.typing import NDArray





def  lowerCamelCase(       SCREAMING_SNAKE_CASE_					,SCREAMING_SNAKE_CASE_    )		->		NDArray[floataa]:
			A_		,   A_       		=   np.shape(SCREAMING_SNAKE_CASE_    )

			A_       		=   np.zeros((rows, 1)					,dtype=SCREAMING_SNAKE_CASE_    )
			for row in reversed(range(SCREAMING_SNAKE_CASE_    )    ):
						A_       		=   0
						for col in range(row + 1					,SCREAMING_SNAKE_CASE_    ):
									total += coefficients[row, col] * x[col]

						A_       		=   (vector[row] - total) / coefficients[row, row]

			return x





def  lowerCamelCase(       SCREAMING_SNAKE_CASE_					,SCREAMING_SNAKE_CASE_    )		->		NDArray[floataa]:
			A_		,   A_       		=   np.shape(SCREAMING_SNAKE_CASE_    )
			if rows != columns:
						return np.array(()					,dtype=SCREAMING_SNAKE_CASE_    )

			# augmented matrix
			A_       		=   np.concatenate((coefficients, vector)					,axis=1    )
			A_       		=   augmented_mat.astype('float64'    )

			# scale the matrix leaving it triangular
			for row in range(rows - 1    ):
						A_       		=   augmented_mat[row, row]
						for col in range(row + 1					,SCREAMING_SNAKE_CASE_    ):
									A_       		=   augmented_mat[col, row] / pivot
									augmented_mat[col, :] -= factor * augmented_mat[row, :]

			A_       		=   retroactive_resolution(
			    augmented_mat[:, 0:columns]					,augmented_mat[:, columns : columns + 1]    )

			return x


if __name__ == "__main__":
							import doctest

							doctest.testmod()










'''simple docstring'''
from __future__ import annotations





def  lowerCamelCase(       SCREAMING_SNAKE_CASE_    )		->		Optional[int]:
			global graph, reversed_graph, scc, component, visit, stack
			if visit[u]:
						return
			A_       		=   True
			for v in graph[u]:
						dfs(SCREAMING_SNAKE_CASE_    )
			stack.append(SCREAMING_SNAKE_CASE_    )





def  lowerCamelCase(       SCREAMING_SNAKE_CASE_    )		->		List[Any]:
			global graph, reversed_graph, scc, component, visit, stack
			if visit[u]:
						return
			A_       		=   True
			component.append(SCREAMING_SNAKE_CASE_    )
			for v in reversed_graph[u]:
						dfsa(SCREAMING_SNAKE_CASE_    )





def  lowerCamelCase(       )		->		int:
			global graph, reversed_graph, scc, component, visit, stack
			for i in range(SCREAMING_SNAKE_CASE_    ):
						dfs(SCREAMING_SNAKE_CASE_    )
			A_       		=   [False] * n
			for i in stack[::-1]:
						if visit[i]:
									continue
						A_       		=   []
						dfsa(SCREAMING_SNAKE_CASE_    )
						scc.append(SCREAMING_SNAKE_CASE_    )
			return scc


if __name__ == "__main__":
							# n - no of nodes, m - no of edges
							_SCREAMING_SNAKE_CASE ,						_SCREAMING_SNAKE_CASE =	list(map(int, input().strip().split()))

							_SCREAMING_SNAKE_CASE =	[[] for _ in range(n)]  # graph
							_SCREAMING_SNAKE_CASE =	[[] for i in range(n)]  # reversed graph
							# input graph data (edges)
							for _ in range(m):
														_SCREAMING_SNAKE_CASE ,						_SCREAMING_SNAKE_CASE =	list(map(int, input().strip().split()))
														graph[u].append(v)
														reversed_graph[v].append(u)

							_SCREAMING_SNAKE_CASE =	[]
							_SCREAMING_SNAKE_CASE =	[False] * n
							_SCREAMING_SNAKE_CASE =	[]
							_SCREAMING_SNAKE_CASE =	[]
							print(kosaraju())




