1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <bits/stdc++.h>
#include "message.h"
#include "sabotaz.h"

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;  
typedef vector <int> VI;
const int INF = 1000000000;
 
int n, m, cnt, odp;
VI in, pi;
vector <VI> adj;

void read(){
	int i, a, b;
	scanf("%d %d", &n, &m);
	n = NumberOfIsles();
	m = NumberOfBridges();
	adj.clear(); adj.resize(n);
	for (i = 0; i < m; ++i){
		a = BridgeEndA(i);
		b = BridgeEndB(i);
		if (a == b) continue;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
}
 
 
void init(){
	in.clear(); 
	in.resize(n,INF);
	pi.resize(n);
	cnt = 1;
}
 
int dfs(int u){
	int ans = u;
	in[u] = cnt++;

	for (int i = 0; i < adj[u].size(); i++){
		int v = adj[u][i];
		if (v == u) continue;
		if (v == pi[u]) continue;
 
		if (in[v]==INF){
			pi[v] = u;
			v = dfs(v);	
		}
		if (in[ans] > in[v]) ans = v;
	}
	if (ans == u && pi[u] != u) odp++;
	return ans;
}
 
int main(void){
	
	read(); 
	init();
	
	for (int u = 0; u < n; u++)
		if (in[u] == INF){
			pi[u] = u;
			dfs(u);
		}
	if (MyNodeId() == 0) cout << odp << endl;	
}