


from __future__ import annotations
def     UpperCAmelCase_ (							__snake_case						)					->      Dict:







 """simple docstring"""


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







 """simple docstring"""


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







 """simple docstring"""


 global graph, reversed_graph, scc, component, visit, stack
 for i in range(__snake_case						):
  dfs(__snake_case						)
 _lowercase											=[False] * n
 for i in stack[::-1]:
  if visit[i]:
   continue
  _lowercase											=[]
  dfsa(__snake_case						)
  scc.append(__snake_case						)
 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())




UpperCAmelCase__            =							[
    [0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0],
    [0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0],
    [0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0],
    [0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0],
]
def     UpperCAmelCase_ (							__snake_case					,						__snake_case					,						__snake_case					,						__snake_case						)					->      bool:







 """simple docstring"""


 return 0 <= row < rows and 0 <= col < cols
def     UpperCAmelCase_ (							__snake_case					,						__snake_case					,						__snake_case					,						__snake_case						)					->      int:







 """simple docstring"""


 _lowercase											=len(__snake_case						)
 _lowercase											=len(mat[0]						)
 if is_safe(__snake_case					,						__snake_case					,						__snake_case					,						__snake_case						) and (row, col) not in seen and mat[row][col] == 1:
  seen.add((row, col)						)
  return (
      1
      + depth_first_search(row + 1					,						__snake_case					,						__snake_case					,						__snake_case						)
      + depth_first_search(row - 1					,						__snake_case					,						__snake_case					,						__snake_case						)
      + depth_first_search(__snake_case					,						col + 1					,						__snake_case					,						__snake_case						)
      + depth_first_search(__snake_case					,						col - 1					,						__snake_case					,						__snake_case						)
  )
 else:
  return 0
def     UpperCAmelCase_ (							__snake_case						)					->      int:







 """simple docstring"""


 _lowercase											=set()

 _lowercase											=0
 for row, line in enumerate(__snake_case						):
  for col, item in enumerate(__snake_case						):
   if item == 1 and (row, col) not in seen:
    # Maximizing the area
    _lowercase											=max(__snake_case					,						depth_first_search(__snake_case					,						__snake_case					,						__snake_case					,						__snake_case						)						)
 return max_area


if __name__ == "__main__":
  import doctest

  print(find_max_area(matrix))  # Output -> 6
  doctest.testmod()

