{"problem":{"name":"Count Connected Components","description":{"content":"You are given a simple undirected graph with $N$ vertices numbered $1$ to $N$ and $M$ edges numbered $1$ to $M$. Edge $i$ connects vertex $u_i$ and vertex $v_i$.   Find the number of connected compone","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc284_c"},"statements":[{"statement_type":"Markdown","content":"You are given a simple undirected graph with $N$ vertices numbered $1$ to $N$ and $M$ edges numbered $1$ to $M$. Edge $i$ connects vertex $u_i$ and vertex $v_i$.  \nFind the number of connected components in this graph.\n\n## Constraints\n\n*   $1 \\leq N \\leq 100$\n*   $0 \\leq M \\leq \\frac{N(N - 1)}{2}$\n*   $1 \\leq u_i, v_i \\leq N$\n*   The given graph is simple.\n*   All values in the input are integers.\n\n## Input\n\nThe input is given from Standard Input in the following format:\n\n$N$ $M$\n$u_1$ $v_1$\n$u_2$ $v_2$\n$\\vdots$\n$u_M$ $v_M$\n\n[samples]\n\n## Notes\n\nA **simple undirected graph** is a graph that is simple and has undirected edges.  \nA graph is **simple** if and only if it has no self-loop or multi-edge.\nA **subgraph** of a graph is a graph formed from some of the vertices and edges of that graph.  \nA graph is **connected** if and only if one can travel between every pair of vertices via edges.  \nA **connected component** is a connected subgraph that is not part of any larger connected subgraph.","is_translate":false,"language":"English"}],"meta":{"iden":"abc284_c","tags":[],"sample_group":[["5 3\n1 2\n1 3\n4 5","2\n\nThe given graph contains the following two connected components:\n\n*   a subgraph formed from vertices $1$, $2$, $3$, and edges $1$, $2$;\n*   a subgraph formed from vertices $4$, $5$, and edge $3$.\n\n![image](https://img.atcoder.jp/ghi/abc284c_095531536446f41896b10cf15a3e4d158ce081ef1b6fe656788371718b39b3fb.jpg)"],["5 0","5"],["4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4","1"]],"created_at":"2026-03-03 11:01:13"}}