





from __future__ import annotations


def        __snake_case       (						lowerCAmelCase_  )							->	int:
    global graph, reversed_graph, scc, component, visit, stack
    if visit[u]:
        return
    SCREAMING_SNAKE_CASE__       							= True
    for v in graph[u]:
        dfs(lowerCAmelCase_  )
    stack.append(lowerCAmelCase_  )


def        __snake_case       (						lowerCAmelCase_  )							->	List[Any]:
    global graph, reversed_graph, scc, component, visit, stack
    if visit[u]:
        return
    SCREAMING_SNAKE_CASE__       							= True
    component.append(lowerCAmelCase_  )
    for v in reversed_graph[u]:
        dfsa(lowerCAmelCase_  )


def        __snake_case       (						)							->	List[Any]:
    global graph, reversed_graph, scc, component, visit, stack
    for i in range(lowerCAmelCase_  ):
        dfs(lowerCAmelCase_  )
    SCREAMING_SNAKE_CASE__       							= [False] * n
    for i in stack[::-1]:
        if visit[i]:
            continue
        SCREAMING_SNAKE_CASE__       							= []
        dfsa(lowerCAmelCase_  )
        scc.append(lowerCAmelCase_  )
    return scc


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

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

  _A				:							list[int]							= []
  _A				:							list[bool]							= [False] * n
  _A				:							list[int]							= []
  _A				:							list[int]							= []
  print(kosaraju())







import io
import json
import subprocess


_A				:							str							= [
    ["""en""", """ru"""],
    ["""ru""", """en"""],
    ["""en""", """de"""],
    ["""de""", """en"""],
]

_A				:							int							= 8


def        __snake_case       (						lowerCAmelCase_   ,       lowerCAmelCase_  )							->	Optional[Any]:
    SCREAMING_SNAKE_CASE__       							= {}
    for src, tgt in pairs:
        SCREAMING_SNAKE_CASE__       							= f'''{src}-{tgt}'''
        SCREAMING_SNAKE_CASE__       							= f'''sacrebleu -t wmt19 -l {pair} --echo src'''.split()
        SCREAMING_SNAKE_CASE__       							= subprocess.run(lowerCAmelCase_   ,       stdout=subprocess.PIPE  ).stdout.decode('''utf-8'''  ).splitlines()
        SCREAMING_SNAKE_CASE__       							= f'''sacrebleu -t wmt19 -l {pair} --echo ref'''.split()
        SCREAMING_SNAKE_CASE__       							= subprocess.run(lowerCAmelCase_   ,       stdout=subprocess.PIPE  ).stdout.decode('''utf-8'''  ).splitlines()
        SCREAMING_SNAKE_CASE__       							= {'''src''': src_lines[:n_objs], '''tgt''': tgt_lines[:n_objs]}
    return text


_A				:							Optional[Any]							= get_all_data(pairs, n_objs)
_A				:							Optional[Any]							= """./fsmt_val_data.json"""
with io.open(filename, """w""", encoding="""utf-8""") as f:
  _A				:							int							= json.dump(text, f, indent=2, ensure_ascii=False)
