import os
from shutil import copyfile
from typing import Optional, Tuple

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import is_sentencepiece_available, logging


if is_sentencepiece_available():
    from .tokenization_reformer import ReformerTokenizer
else:
    lowerCAmelCase__					=				None


lowerCAmelCase__					=				logging.get_logger(__name__)


lowerCAmelCase__					=				'▁'

lowerCAmelCase__					=				{'vocab_file': 'spiece.model', 'tokenizer_file': 'tokenizer.json'}

lowerCAmelCase__					=				{
    'vocab_file': {
        'google/reformer-crime-and-punishment': (
            'https://huggingface.co/google/reformer-crime-and-punishment/resolve/main/spiece.model'
        )
    },
    'tokenizer_file': {
        'google/reformer-crime-and-punishment': (
            'https://huggingface.co/google/reformer-crime-and-punishment/resolve/main/tokenizer.json'
        )
    },
}

lowerCAmelCase__					=				{
    'google/reformer-crime-and-punishment': 524288,
}
class        a_				(		SCREAMING_SNAKE_CASE		):






 '''simple docstring'''






 UpperCAmelCase_							=      VOCAB_FILES_NAMES
 UpperCAmelCase_							=      PRETRAINED_VOCAB_FILES_MAP
 UpperCAmelCase_							=      PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
 UpperCAmelCase_							=      ["input_ids", "attention_mask"]
 UpperCAmelCase_							=      ReformerTokenizer




 def __init__(    self      :						Optional[int]    ,					lowercase__      :						List[str]=None    ,					lowercase__      :						Any=None    ,					lowercase__      :						str="</s>"    ,					lowercase__      :						str="<unk>"    ,					lowercase__      :						str=[]    ,					**lowercase__      :						str    ,					):







        '''simple docstring'''



        super().__init__(
            lowercase__    ,					tokenizer_file=lowercase__    ,					eos_token=lowercase__    ,					unk_token=lowercase__    ,					additional_special_tokens=lowercase__    ,					**lowercase__    ,					)

        lowerCAmelCase__  			=      vocab_file
        lowerCAmelCase__  			=      False if not self.vocab_file else True




 def 	__snake_case		(    self      :						Optional[Any]    ,					lowercase__      :						List[Any]    ,					lowercase__      :						Dict = None):







        '''simple docstring'''



        if not self.can_save_slow_tokenizer:
               raise ValueError(
                   'Your fast tokenizer does not have the necessary information to save the vocabulary for a slow '
                   'tokenizer.')

        if not os.path.isdir(lowercase__):
               logger.error(F'''Vocabulary path ({save_directory}) should be a directory''')
               return
        lowerCAmelCase__  			=      os.path.join(
            lowercase__    ,					(filename_prefix + '-' if filename_prefix else '') + VOCAB_FILES_NAMES['vocab_file'])

        if os.path.abspath(self.vocab_file) != os.path.abspath(lowercase__):
               copyfile(self.vocab_file    ,					lowercase__)

        return (out_vocab_file,)

from __future__ import annotations






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






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






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


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

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

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