output_description: Print the number of the edges that are bridges among the M edges.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N M  
      a_1 b_1  
      a_2 b_2
      :  
      a_M b_M
attempt: from queue import LifoQueue
  from collections import defaultdict
  
  
  def solve(n, m, AB):
      g = defaultdict(lambda: [])
      for a, b in AB:
          g[a].append(b)
          g[b].append(a)
      q = LifoQueue(maxsize=m)
      q.put((0, 1, 0))
      s = {1}
  
      total = m
      ng_count = 0
      while not q.empty():
          p, c, l = q.get()
          cands = [n for n in g[c] if n != p]
          size = len(cands)
          count = 0
          for n in cands:
              if n not in s:
                  nl = l
                  if l > 0 and size == 1:
                      # 分岐後の一本道の場合は長さを+1
                      nl += 1
                  if size >= 2:
                      # 分岐の場合は長さをリセット
                      nl = 1
                  q.put((c, n, nl))
                  s.add(n)
              else:
                  # 既出の点が発見されたらそこまでの長さを引く
                  ng_count += 1
                  total -= l + 1
                  count += 1
          if count > 0:
              # 同じ辺を複数削除してしまった場合に追加
              total += (count - 1) * l
      return total + ng_count // 2  # 重複削除のために追加
  
  
  _n, _m = map(int, input().split())
  _AB = [map(int, input().split()) for _ in range(_m)]
  print(solve(_n, _m, _AB))
  
problem_description: Statement
  
  You are given an undirected connected graph with N vertices and M edges that
  does not contain self-loops and double edges.  
  The i-th edge (1 \leq i \leq M) connects Vertex a_i and Vertex b_i.
  
  An edge whose removal disconnects the graph is called a _bridge_.  
  Find the number of the edges that are bridges among the M edges.
samples: [{"input": "7 7\n    1 3\n    2 7\n    3 4\n    4 5\n    4 6\n    5 6\n    6 7", "output": "4\n    \n\nThe figure below shows the given graph:\n\n![570677a9809fd7a5b63bff11e5d9bf79.png](https://img.atcoder.jp/abc075/570677a9809fd7a5b63bff11e5d9bf79.png)\n\nThe edges shown in red are bridges. There are four of them.\n\n* * *"}, {"input": "3 3\n    1 2\n    1 3\n    2 3", "output": "0\n    \n\nIt is possible that there is no bridge.\n\n* * *"}, {"input": "6 5\n    1 2\n    2 3\n    3 4\n    4 5\n    5 6", "output": "5\n    \n\nIt is possible that every edge is a bridge."}]