#include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef pair pint; typedef vector vint; typedef vector vpint; #define mp make_pair #define fi first #define se second #define all(v) (v).begin(),(v).end() #define rep(i,n) for(int i=0;i<(n);i++) #define reps(i,f,n) for(int i=(f);i<(n);i++) int h, w; string s[55]; int main(void){ cin >> h >> w; ll ans = 0; rep(i, h) cin >> s[i]; for (int i = 0; i < h; ++i){ for (int j = 0; j < w - 1; ++j){ if(s[i][j] == 'w' && s[i][j + 1] == 'b'){ ans += 100; s[i][j] = '.'; s[i][j + 1] = '.'; } if(s[i][j] == 'b' && s[i][j + 1] == 'w'){ ans += 100; s[i][j] = '.'; s[i][j + 1] = '.'; } } } for (int i = 0; i < h - 1; ++i){ for (int j = 0; j < w; ++j){ if(s[i][j] == 'w' && s[i + 1][j] == 'b'){ ans += 100; s[i][j] = '.'; s[i + 1][j] = '.'; } if(s[i][j] == 'b' && s[i + 1][j] == 'w'){ ans += 100; s[i][j] = '.'; s[i + 1][j] = '.'; } } } int cntb = 0, cntw = 0; rep(i, h)rep(j, w){ if(s[i][j] == 'w') cntw++; if(s[i][j] == 'b') cntb++; } if(cntw < cntb) swap(cntw, cntb); int wan = cntw - cntb; ans += 10 * cntb; ans += wan; printf("%lld\n", ans); return 0; }