#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
//using namespace __gnu_pbds;
 
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define fp(i,a,b) for(int i=a ; i<b ; i++)
#define fn(i,a,b) for(int i=a ; i>=b ; i--)
#define ones(x) __builtin_popcount(x)
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define dbg(x) cout << (#x) << " = " << x << " "
#define fini cout << "\n";
#define line cout << "-----------------------------------\n";
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;/*
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;*/
/*
int read (){
    int x = 0, f = 1; char s = getchar();while (s < '0' || s > '9') {if (s == '-') f = -1; s = getchar();}
    while (s >= '0' && s <= '9') x = x * 10 + s - '0', s = getchar();
    return x * f; 
}*/
const int M=1e1+7;
const int N=1e4+7;
const ll inf=1e18;
const int mod=2147483647;

int h,w;
char mat[12][12];

void go(){
    cin >> h >> w;
    fp(i,1,h+1) fp(j,1,w+1) cin >> mat[i][j];

    int n = 0;
    fp(i,1,h){
        int acum = 0;
        fp(j,1,w+1){
            if (mat[i][j] == mat[i+1][j]){
                if (acum != 0) n++;
                acum = 0;
            }
            else acum++;
        }
    }

    fp(j,1,w){
        int acum = 0;
        fp(i,1,h+1){
            if (mat[i][j] == mat[i][j+1]){
                if (acum != 0) n++;
                acum = 0;
            }
            else acum++;
        }
    }

    cout << n << "\n";
}
 
int main(){ 
 
    fastio;
    int tst = 1;
    // cout << fixed << setprecision(12);
    // cin >> tst;
    fp(i,0,tst) go();
 
    return 0;
}
#include "bits/stdc++.h"
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, m = 0, n = 0, p = 0, q = 0, mod = 1000000007;
    string s;
    cin >> a >> b;
    vector<vector<char>> v(a,vector<char>(b));
    for(int i=0;i<a;i++)
    {
       for(int j=0;j<b;j++)
       {
           cin >> v.at(i).at(j);
       }
    }
    for(int i=0;i<a-1;i++)
    {
        for(int j=0;j<b-1;j++)
        {
            c=0;d=0;
            for(int k=0;k<2;k++)
            {
                for(int l=0;l<2;l++)
                {
                    if(v.at(i+k).at(j+l)=='.')
                    {
                        c++;
                    }
                    else
                    {
                        d++;
                    }
                }
            }
            if(c==3||d==3)
            n++;
        }
    }
    cout << n;
    return 0;
}