
"""simple docstring"""

from transformers import SqueezeBertTokenizer, SqueezeBertTokenizerFast
from transformers.testing_utils import require_tokenizers, slow

from ..bert.test_tokenization_bert import BertTokenizationTest
@require_tokenizers
class    _UpperCAmelCase							(						SCREAMING_SNAKE_CASE_							):
      __SCREAMING_SNAKE_CASE      :							Any												=		SqueezeBertTokenizer
      __SCREAMING_SNAKE_CASE      :							Optional[Any]												=		SqueezeBertTokenizerFast
      __SCREAMING_SNAKE_CASE      :							Dict												=		True




      def 			a_					(							self      ,				**lowercase_							)  ->    Any:
          return SqueezeBertTokenizerFast.from_pretrained(self.tmpdirname      ,				**lowercase_							)




      @slow
      def 			a_					(							self							)  ->    Optional[int]:
          UpperCAmelCase  	=    SqueezeBertTokenizer.from_pretrained('squeezebert/squeezebert-mnli-headless'							)

          UpperCAmelCase  	=    tokenizer.encode('sequence builders'      ,				add_special_tokens=lowercase_							)
          UpperCAmelCase  	=    tokenizer.encode('multi-sequence build'      ,				add_special_tokens=lowercase_							)

          UpperCAmelCase  	=    tokenizer.build_inputs_with_special_tokens(lowercase_							)
          UpperCAmelCase  	=    tokenizer.build_inputs_with_special_tokens(lowercase_      ,				lowercase_							)

          assert encoded_sentence == [tokenizer.cls_token_id] + text + [tokenizer.sep_token_id]
          assert encoded_pair == [tokenizer.cls_token_id] + text + [tokenizer.sep_token_id] + text_a + [
              tokenizer.sep_token_id
          ]





"""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())



