






"""simple docstring"""





from __future__ import annotations






def     A(  snake_case_		):
       """simple docstring"""





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






def     A(  snake_case_		):
       """simple docstring"""





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






def     A(  ):
       """simple docstring"""





       global graph, reversed_graph, scc, component, visit, stack
       for i in range(__UpperCamelCase		):
              dfs(__UpperCamelCase		)
       lowercase__:    List[Any]        =      [False] * n
       for i in stack[::-1]:
              if visit[i]:
                     continue
              lowercase__:    Union[str, Any]        =      []
              dfsa(__UpperCamelCase		)
              scc.append(__UpperCamelCase		)
       return scc


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

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

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














"""simple docstring"""





from __future__ import annotations






def     A(  snake_case_						,       snake_case_		):
       """simple docstring"""





       lowercase__  ,     lowercase__:    Optional[int]        =      0, len(snake_case_		) - 1
       while start_ind <= end_ind:
              if array[start_ind] == search_item:
                     return start_ind
              elif array[end_ind] == search_item:
                     return end_ind
              else:
                     start_ind += 1
                     end_ind -= 1
    # returns -1 if search_item is not found in array
       return -1


if __name__ == "__main__":
  print(double_linear_search(list(range(1_00)), 40))






