
'''simple docstring'''

def __A  (    lowerCAmelCase_       ):
     return -num if num < 0 else num







def __A  (    lowerCAmelCase_       ):
     if len(lowerCAmelCase_       ) == 0:
          raise ValueError("""abs_min() arg is an empty sequence"""       )
     _UpperCAmelCase					:  str         =    x[0]
     for i in x:
          if abs_val(lowerCAmelCase_       ) < abs_val(lowerCAmelCase_       ):
               _UpperCAmelCase					:  Dict         =    i
     return j







def __A  (    lowerCAmelCase_       ):
     if len(lowerCAmelCase_       ) == 0:
          raise ValueError("""abs_max() arg is an empty sequence"""       )
     _UpperCAmelCase					:  Optional[Any]         =    x[0]
     for i in x:
          if abs(lowerCAmelCase_       ) > abs(lowerCAmelCase_       ):
               _UpperCAmelCase					:  Optional[Any]         =    i
     return j







def __A  (    lowerCAmelCase_       ):
     if len(lowerCAmelCase_       ) == 0:
          raise ValueError("""abs_max_sort() arg is an empty sequence"""       )
     return sorted(lowerCAmelCase_ ,       key=lowerCAmelCase_       )[-1]







def __A  (    ):
     assert abs_val(0       ) == 0
     assert abs_val(34       ) == 34
     assert abs_val(-1000_0000_0000       ) == 1000_0000_0000

     _UpperCAmelCase					:  List[str]         =    [-3, -1, 2, -11]
     assert abs_max(lowerCAmelCase_       ) == -11
     assert abs_max_sort(lowerCAmelCase_       ) == -11
     assert abs_min(lowerCAmelCase_       ) == -1


if __name__ == "__main__":
   import doctest

   doctest.testmod()

   test_abs_val()
   print(abs_val(-34))  # --> 34




"""simple docstring"""

from __future__ import annotations




def 			lowercase__  (    lowerCAmelCase :    Dict       )       ->					Optional[int]:






    """simple docstring"""




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




def 			lowercase__  (    lowerCAmelCase :    Optional[int]       )       ->					int:






    """simple docstring"""




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




def 			lowercase__  (    )       ->					List[str]:






    """simple docstring"""




    global graph, reversed_graph, scc, component, visit, stack
    for i in range(lowerCAmelCase       ):
        dfs(lowerCAmelCase       )
    UpperCAmelCase  	=    [False] * n
    for i in stack[::-1]:
        if visit[i]:
            continue
        UpperCAmelCase  	=    []
        dfsa(lowerCAmelCase       )
        scc.append(lowerCAmelCase       )
    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())



