{"raw_statement":[{"iden":"statement","content":"You are given an undirected graph consisting of $n$ vertices and $m$ edges. Your task is to find the number of connected components which are cycles.\n\nHere are some definitions of graph theory.\n\nAn undirected graph consists of two sets: set of nodes (called vertices) and set of edges. Each edge connects a pair of vertices. All edges are bidirectional (i.e. if a vertex $a$ is connected with a vertex $b$, a vertex $b$ is also connected with a vertex $a$). An edge can't connect vertex with itself, there is at most one edge between a pair of vertices.\n\nTwo vertices $u$ and $v$ belong to the same connected component if and only if there is at least one path along edges connecting $u$ and $v$.\n\nA connected component is a cycle if and only if its vertices can be reordered in such a way that:\n\n*   the first vertex is connected with the second vertex by an edge,\n*   the second vertex is connected with the third vertex by an edge,\n*   ...\n*   the last vertex is connected with the first vertex by an edge,\n*   all the described edges of a cycle are distinct.\n\nA cycle doesn't contain any other edges except described above. By definition any cycle contains three or more vertices.\n\n<center>![image](https://espresso.codeforces.com/2efb48fd56a6167cac3c5a8c51483513d9b48b30.png) There are $6$ connected components, $2$ of them are cycles: $[7, 10, 16]$ and $[5, 11, 9, 15]$.</center>"},{"iden":"input","content":"The first line contains two integer numbers $n$ and $m$ ($1 \\le n \\le 2 \\cdot 10^5$, $0 \\le m \\le 2 \\cdot 10^5$) — number of vertices and edges.\n\nThe following $m$ lines contains edges: edge $i$ is given as a pair of vertices $v_i$, $u_i$ ($1 \\le v_i, u_i \\le n$, $u_i \\ne v_i$). There is no multiple edges in the given graph, i.e. for each pair ($v_i, u_i$) there no other pairs ($v_i, u_i$) and ($u_i, v_i$) in the list of edges."},{"iden":"output","content":"Print one integer — the number of connected components which are also cycles."},{"iden":"examples","content":"Input\n\n5 4\n1 2\n3 4\n5 4\n3 5\n\nOutput\n\n1\n\nInput\n\n17 15\n1 8\n1 12\n5 11\n11 9\n9 15\n15 5\n4 13\n3 13\n4 3\n10 16\n7 10\n16 7\n14 3\n14 4\n17 6\n\nOutput\n\n2"},{"iden":"note","content":"In the first example only component $[3, 4, 5]$ is also a cycle.\n\nThe illustration above corresponds to the second example."}],"translated_statement":[{"iden":"statement","content":"你被给定一个包含 $n$ 个顶点和 $m$ 条边的无向图。你的任务是找出有多少个连通分量是环。\n\n以下是图论的一些定义。\n\n一个无向图由两个集合组成：顶点集合和边集合。每条边连接一对顶点。所有边都是双向的（即如果顶点 $a$ 与顶点 $b$ 相连，则顶点 $b$ 也与顶点 $a$ 相连）。边不能连接顶点与自身，一对顶点之间最多只有一条边。\n\n两个顶点 $u$ 和 $v$ 属于同一个连通分量，当且仅当存在至少一条沿边连接 $u$ 和 $v$ 的路径。\n\n一个连通分量是环，当且仅当它的顶点可以重新排列，使得：\n\n环中不包含除上述之外的其他边。根据定义，任何环都包含三个或更多顶点。\n\n第一行包含两个整数 $n$ 和 $m$（$1 lt.eq n lt.eq 2 dot.op 10^5$，$0 lt.eq m lt.eq 2 dot.op 10^5$）——分别表示顶点数和边数。\n\n接下来的 $m$ 行每行给出一条边：第 $i$ 条边由一对顶点 $v_i$、$u_i$ 给出（$1 lt.eq v_i, u_i lt.eq n$，$u_i != v_i$）。给定图中不存在重边，即对于每对 $(v_i, u_i)$，在边列表中不存在其他对 $(v_i, u_i)$ 或 $(u_i, v_i)$。\n\n请输出一个整数——既是环的连通分量的数量。\n\n在第一个例子中，只有分量 $[ 3, 4, 5 ]$ 是一个环。\n\n上述图示对应第二个例子。\n\n"},{"iden":"input","content":"第一行包含两个整数 $n$ 和 $m$（$1 lt.eq n lt.eq 2 dot.op 10^5$，$0 lt.eq m lt.eq 2 dot.op 10^5$）——分别表示顶点数和边数。接下来的 $m$ 行每行给出一条边：第 $i$ 条边由一对顶点 $v_i$、$u_i$ 给出（$1 lt.eq v_i, u_i lt.eq n$，$u_i != v_i$）。给定图中不存在重边，即对于每对 $(v_i, u_i)$，在边列表中不存在其他对 $(v_i, u_i)$ 或 $(u_i, v_i)$。"},{"iden":"output","content":"请输出一个整数——既是环的连通分量的数量。"},{"iden":"examples","content":"输入\n5 4\n1 2\n3 4\n5 4\n3 5\n输出\n1\n\n输入\n17 15\n1 8\n1 12\n5 11\n11 9\n9 15\n15 5\n4 13\n3 13\n4 3\n10 16\n7 10\n16 7\n14 3\n14 4\n17 6\n输出\n2"},{"iden":"note","content":"在第一个例子中，只有分量 $[ 3, 4, 5 ]$ 是一个环。上述图示对应第二个例子。"}],"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ G = (V, E) $ be an undirected graph with:  \n- $ V $: set of vertices, $ |V| = n $  \n- $ E $: set of edges, $ |E| = m $  \n\nA **connected component** is a maximal connected subgraph of $ G $.  \nA connected component $ C = (V_C, E_C) $ is a **cycle** if and only if:  \n- $ |V_C| \\geq 3 $,  \n- Every vertex in $ V_C $ has degree 2 in $ C $,  \n- $ |E_C| = |V_C| $.  \n\n**Constraints**  \n1. $ 1 \\leq n \\leq 2 \\cdot 10^5 $  \n2. $ 0 \\leq m \\leq 2 \\cdot 10^5 $  \n3. No self-loops or multiple edges.  \n\n**Objective**  \nCompute the number of connected components $ C $ of $ G $ such that $ C $ is a cycle.","simple_statement":null,"has_page_source":false}