#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
#define MAX_V 2500

char choco[50][50];
int V=MAX_V;
vector<int> G[MAX_V];
int match[MAX_V];
bool used[MAX_V];

void add_edge(int u,int v){
    G[u].push_back(v);
    G[v].push_back(u);
}

bool dfs(int v){
    used[v]=true;
    for(int i=0;i<G[v].size();i++){
        int u=G[v][i], w=match[u];
        if(w<0||(!used[w]&&dfs(w))){
            match[v]=u;
            match[u]=v;
            return true;
        }
    }
    return false;
}

int bipartite_matching(){
    int res=0;
    fill(match,match+MAX_V,-1);
    for(int v=0;v<V;v++){
        if(match[v]<0){
            fill(used,used+MAX_V,false);
            if(dfs(v)){
                res++;
            }
        }
    }
    return res;
}

int main(){
    int N,M;
    cin>>N>>M;
    for(int i=0;i<N;i++){
        for(int j=0;j<M;j++){
            cin>>choco[i][j];
        }
    }
    int white=0,black=0;
    for(int i=0;i<N;i++){
        for(int j=0;j<M;j++){
            if(choco[i][j]=='.') continue;
            if(choco[i][j]=='w'){
                white++;
            }else{
                black++;
            }
            int d[3]={0,1,0};
            for(int k=0;k<2;k++){
                int I=i+d[k],J=j+d[k+1];
                if(I>=0&&I<N&&J>=0&&J<M){
                    if(choco[I][J]!='.'){
                        add_edge(i*50+j,I*50+J);
                    }
                }
            }
        }
    }
    int P=bipartite_matching();
    int score=100*P;
    white-=P;black-=P;
    score+=10*min(white,black);
    score+=max(white,black)-min(white,black);
    cout<<score<<endl;
    return 0;
}