#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace atcoder; using namespace std; using ll=long long; using ull=unsigned long long; using P=pair; templateusing minque=priority_queue,greater>; templatebool chmax(T &a,const T &b){return (abool chmin(T &a,const T &b){return (a>b?(a=b,true):false);} template ostream &operator<<(ostream &os,const pair&p){ os< istream &operator>>(istream &is,pair&p){ is>>p.first>>p.second; return is; } template istream &operator>>(istream &is,vector &a){ for(auto &i:a)is>>i; return is; } #define reps(i,a,n) for(int i=(a);i<(n);i++) #define rep(i,n) reps(i,0,n) #define all(x) x.begin(),x.end() ll myceil(ll a,ll b){return (a+b-1)/b;} int main(){ int h,w; cin>>h>>w; vectors(h); cin>>s; mf_graphg(h*w+2); rep(i,h)rep(j,w)if(s[i][j]!='.'){ if(s[i][j]=='w')g.add_edge(h*w,i*w+j,1); else g.add_edge(i*w+j,h*w+1,1); } rep(i,h)rep(j,w)if(s[i][j]=='w'){ if(ib)swap(a,b); ans+=10*a; ans+=b-a; cout<