
'''simple docstring'''





import math
from decimal import Decimal, getcontext





def     snake_case							(						UpperCAmelCase = 4_0_0_0_0_0_0		)->     int:







      """simple docstring"""

      try:
            __A    		=     int(UpperCAmelCase		)
      except (TypeError, ValueError):
            raise TypeError('Parameter n must be int or castable to int.'		)
      if n <= 0:
            raise ValueError('Parameter n must be greater than or equal to one.'		)
      __A    		=     1_0_0
      __A    		=     (Decimal(5		) ** Decimal(0.5		) + 1) / Decimal(2		)

      __A    		=     (math.floor(math.log(n * (phi + 2) ,					UpperCAmelCase		) - 1		) // 3) * 3 + 2
      __A    		=     Decimal(round(phi ** Decimal(index + 1		)		)		) / (phi + 2)
      __A    		=     num // 2
      return int(UpperCAmelCase		)


if __name__ == "__main__":
 print(f'''{solution() = }''')








'''simple docstring'''





from __future__ import annotations





def     snake_case							(						UpperCAmelCase		)->     List[Any]:







      """simple docstring"""
      global graph, reversed_graph, scc, component, visit, stack
      if visit[u]:
            return
      __A    		=     True
      for v in graph[u]:
            dfs(UpperCAmelCase		)
      stack.append(UpperCAmelCase		)





def     snake_case							(						UpperCAmelCase		)->     List[Any]:







      """simple docstring"""
      global graph, reversed_graph, scc, component, visit, stack
      if visit[u]:
            return
      __A    		=     True
      component.append(UpperCAmelCase		)
      for v in reversed_graph[u]:
            dfsa(UpperCAmelCase		)





def     snake_case							(						)->     Any:







      """simple docstring"""
      global graph, reversed_graph, scc, component, visit, stack
      for i in range(UpperCAmelCase		):
            dfs(UpperCAmelCase		)
      __A    		=     [False] * n
      for i in stack[::-1]:
            if visit[i]:
                  continue
            __A    		=     []
            dfsa(UpperCAmelCase		)
            scc.append(UpperCAmelCase		)
      return scc


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

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

 a__						:				list[int]           =    []
 a__						:				list[bool]           =    [False] * n
 a__						:				list[int]           =    []
 a__						:				list[int]           =    []
 print(kosaraju())






