Don’t be cycle

AtCoder
IDabc288_c
Time2000ms
Memory256MB
Difficulty
You are given a simple undirected graph with $N$ vertices and $M$ edges. The vertices are numbered $1$ to $N$, and the $i$\-th edge connects vertex $A_i$ and vertex $B_i$. Let us delete zero or more edges to remove cycles from the graph. Find the minimum number of edges that must be deleted for this purpose. What is a simple undirected graph? **A simple undirected graph** is a graph without self-loops or multi-edges whose edges have no direction. What is a cycle? A **cycle** in a simple undirected graph is a sequence of vertices $(v_0, v_1, \ldots, v_{n-1})$ of length at least $3$ satisfying $v_i \neq v_j$ if $i \neq j$ such that for each $0 \leq i < n$, there is an edge between $v_i$ and $v_{i+1 \bmod n}$. ## Constraints * $1 \leq N \leq 2 \times 10^5$ * $0 \leq M \leq 2 \times 10^5$ * $1 \leq A_i, B_i \leq N$ * The given graph is simple. * All values in the input are integers. ## Input The input is given from Standard Input in the following format: $N$ $M$ $A_1$ $B_1$ $A_2$ $B_2$ $\vdots$ $A_M$ $B_M$ [samples]
Samples
Input #1
6 7
1 2
1 3
2 3
4 2
6 5
4 6
4 5
Output #1
2

One way to remove cycles from the graph is to delete the two edges between vertex $1$ and vertex $2$ and between vertex $4$ and vertex $5$.  
There is no way to remove cycles from the graph by deleting one or fewer edges, so you should print $2$.
Input #2
4 2
1 2
3 4
Output #2
0
Input #3
5 3
1 2
1 3
2 3
Output #3
1
API Response (JSON)
{
  "problem": {
    "name": "Don’t be cycle",
    "description": {
      "content": "You are given a simple undirected graph with $N$ vertices and $M$ edges. The vertices are numbered $1$ to $N$, and the $i$\\-th edge connects vertex $A_i$ and vertex $B_i$. Let us delete zero or more e",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc288_c"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You are given a simple undirected graph with $N$ vertices and $M$ edges. The vertices are numbered $1$ to $N$, and the $i$\\-th edge connects vertex $A_i$ and vertex $B_i$. Let us delete zero or more e...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments