import functools
import operator

from ...configuration_utils import PretrainedConfig
from ...utils import logging


lowerCAmelCase__					=				logging.get_logger(__name__)

lowerCAmelCase__					=				{
    'facebook/hubert-base-ls960': 'https://huggingface.co/facebook/hubert-base-ls960/resolve/main/config.json',
    # See all Hubert models at https://huggingface.co/models?filter=hubert
}
class        a_				(		SCREAMING_SNAKE_CASE		):






 '''simple docstring'''






 UpperCAmelCase_							=      'hubert'




 def __init__(    self      :						Union[str, Any]    ,					lowercase__      :						Union[str, Any]=32    ,					lowercase__      :						Dict=768    ,					lowercase__      :						Optional[Any]=12    ,					lowercase__      :						Any=12    ,					lowercase__      :						Optional[int]=3_072    ,					lowercase__      :						Any="gelu"    ,					lowercase__      :						Optional[Any]=0.1    ,					lowercase__      :						Any=0.1    ,					lowercase__      :						Optional[Any]=0.1    ,					lowercase__      :						Tuple=True    ,					lowercase__      :						Any=0.0    ,					lowercase__      :						Tuple=0.1    ,					lowercase__      :						Optional[int]=0.1    ,					lowercase__      :						Dict=0.02    ,					lowercase__      :						Any=1e-5    ,					lowercase__      :						List[Any]="group"    ,					lowercase__      :						List[Any]="gelu"    ,					lowercase__      :						Tuple=(512, 512, 512, 512, 512, 512, 512)    ,					lowercase__      :						Any=(5, 2, 2, 2, 2, 2, 2)    ,					lowercase__      :						str=(10, 3, 3, 3, 3, 2, 2)    ,					lowercase__      :						List[Any]=False    ,					lowercase__      :						str=128    ,					lowercase__      :						Dict=16    ,					lowercase__      :						Tuple=False    ,					lowercase__      :						Optional[Any]=True    ,					lowercase__      :						int=0.05    ,					lowercase__      :						List[str]=10    ,					lowercase__      :						Tuple=2    ,					lowercase__      :						str=0.0    ,					lowercase__      :						Any=10    ,					lowercase__      :						Union[str, Any]=0    ,					lowercase__      :						Dict="sum"    ,					lowercase__      :						str=False    ,					lowercase__      :						Optional[Any]=False    ,					lowercase__      :						Tuple=256    ,					lowercase__      :						Union[str, Any]=0    ,					lowercase__      :						List[Any]=1    ,					lowercase__      :						List[str]=2    ,					**lowercase__      :						Any    ,					):







        '''simple docstring'''



        super().__init__(**lowercase__    ,					pad_token_id=lowercase__    ,					bos_token_id=lowercase__    ,					eos_token_id=lowercase__)
        lowerCAmelCase__  			=      hidden_size
        lowerCAmelCase__  			=      feat_extract_norm
        lowerCAmelCase__  			=      feat_extract_activation
        lowerCAmelCase__  			=      list(lowercase__)
        lowerCAmelCase__  			=      list(lowercase__)
        lowerCAmelCase__  			=      list(lowercase__)
        lowerCAmelCase__  			=      conv_bias
        lowerCAmelCase__  			=      num_conv_pos_embeddings
        lowerCAmelCase__  			=      num_conv_pos_embedding_groups
        lowerCAmelCase__  			=      len(self.conv_dim)
        lowerCAmelCase__  			=      num_hidden_layers
        lowerCAmelCase__  			=      intermediate_size
        lowerCAmelCase__  			=      hidden_act
        lowerCAmelCase__  			=      num_attention_heads
        lowerCAmelCase__  			=      hidden_dropout
        lowerCAmelCase__  			=      attention_dropout
        lowerCAmelCase__  			=      activation_dropout
        lowerCAmelCase__  			=      feat_proj_layer_norm
        lowerCAmelCase__  			=      feat_proj_dropout
        lowerCAmelCase__  			=      final_dropout
        lowerCAmelCase__  			=      layerdrop
        lowerCAmelCase__  			=      layer_norm_eps
        lowerCAmelCase__  			=      initializer_range
        lowerCAmelCase__  			=      vocab_size
        lowerCAmelCase__  			=      do_stable_layer_norm
        lowerCAmelCase__  			=      use_weighted_layer_sum
        lowerCAmelCase__  			=      classifier_proj_size

        if (
            (len(self.conv_stride) != self.num_feat_extract_layers)
            or (len(self.conv_kernel) != self.num_feat_extract_layers)
            or (len(self.conv_dim) != self.num_feat_extract_layers)
        ):
               raise ValueError(
                   'Configuration for convolutional layers is incorrect. It is required that `len(config.conv_dim)` =='
                   ' `len(config.conv_stride)` == `len(config.conv_kernel)`, but is `len(config.conv_dim) ='
                   F""" {len(self.conv_dim)}`, `len(config.conv_stride) = {len(self.conv_stride)}`,"""
                   F""" `len(config.conv_kernel) = {len(self.conv_kernel)}`.""")

        # fine-tuning config parameters for SpecAugment: https://arxiv.org/abs/1904.08779
        lowerCAmelCase__  			=      apply_spec_augment
        lowerCAmelCase__  			=      mask_time_prob
        lowerCAmelCase__  			=      mask_time_length
        lowerCAmelCase__  			=      mask_time_min_masks
        lowerCAmelCase__  			=      mask_feature_prob
        lowerCAmelCase__  			=      mask_feature_length
        lowerCAmelCase__  			=      mask_feature_min_masks

        # ctc loss
        lowerCAmelCase__  			=      ctc_loss_reduction
        lowerCAmelCase__  			=      ctc_zero_infinity




 @property
 def 	__snake_case		(    self      :						Optional[int]):







        '''simple docstring'''



        return functools.reduce(operator.mul    ,					self.conv_stride    ,					1)

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