#include using namespace std; using Int = long long; template inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template inline void chmax(T1 &a,T2 b){if(a > G; vector match,level; BiMatch(){} BiMatch(int L,int R):L(L),R(R),G(L+R),match(L+R,-1),level(L){} void add_edge(int u,int v){ G[u].push_back(v+L); G[v+L].push_back(u); } bool bfs(){ queue q; for(int i=0;ilevel[v]&&dfs(w))){ match[v]=u; match[u]=v; return true; } } return false; } int build(){ int res=0; while(bfs()) for(int i=0;i>h>>w; vector s(h); for(int i=0;i>s[i]; int wc=0,bc=0; using P = pair; map ws,bs; for(int i=0;i=0&&s[i-1][j]=='b') bm.add_edge(ws[P(i,j)],bs[P(i-1,j)]); if(j+1< w&&s[i][j+1]=='b') bm.add_edge(ws[P(i,j)],bs[P(i,j+1)]); if(j-1>=0&&s[i][j-1]=='b') bm.add_edge(ws[P(i,j)],bs[P(i,j-1)]); } } int k=bm.build(); int d=min(wc,bc)-k; int ans=k*100+d*10+wc+bc-2*(k+d); cout<