#include using namespace std; const int maxn = 1005; vector z[10005]; int n1, n2, m, ans, N, M; void add_edge(int s,int e) { z[s].push_back(e); } bool vis[10005]; char choco[105][105]; int result[10005]; bool dfs(int i) { for (int k=0;k> N >> M; for (int i = 1;i <= N;i++) { for (int j = 1;j <= M;j++) { cin >> choco[i][j]; } } for (int i = 1;i <= N;i++) { for (int j = 1;j <= M;j++) { if(choco[i][j] == 'b') { n1++; if(choco[i][j+1]=='w') { add_edge(n1, zb(i, j+1)); } if(choco[i+1][j]=='w') { add_edge(n1, zb(i+1, j)); } if(choco[i][j-1]=='w') { add_edge(n1, zb(i, j-1)); } if(choco[i-1][j]=='w') { add_edge(n1, zb(i-1, j)); } } if(choco[i][j] == 'w') n2++; } } for (int i=1;i<=n1;i++) { memset(vis,false,sizeof(vis)); if (dfs(i)) ans++; } if(n1 > n2) cout << ans*100 + (n2-ans)*10 + n1-n2; if(n1 <= n2) cout << ans*100 + (n1-ans)*10 + n2-n1; }