#include <bits/stdc++.h>
using namespace std;

#ifdef LOCAL
#include "/debug.h"
#else
#define db(...)
#endif

#define all(v) v.begin(), v.end()
#define pb push_back
using ll = long long;
const int NAX = 5000 + 5;

constexpr int64_t MOD = 998244353;
int pw[NAX][NAX];

int add(int a, int b)
{
    a += b;
    if (a >= MOD)
        a -= MOD;
    return a;
}

int mul(int a, int b)
{
    return (a * 1LL * b) % MOD;
}

int64_t solveCase(int64_t N, int64_t M)
{
    for (size_t i = 0; i < NAX; i++)
    {
        pw[i][0] = 1;
        for (size_t j = 1; j < NAX; j++)
            pw[i][j] = (i * 1LL * pw[i][j - 1]) % MOD;
    }
    int64_t res = 0;
    for (size_t i = 0; i < N; i++)
        for (size_t x = 1; x <= M; x++)
            res = add(res, mul(pw[M - x][i], pw[M][N - 1 - i]));
    for (size_t d = 1; d < N; d++)
        for (size_t x = 1; x <= M; x++)
            res = add(res, mul(mul(N - d, x - 1), mul(pw[M - x][d - 1], pw[M][N - 1 - d])));
    return res;
}

// generated by oj-template v4.7.2 (https://github.com/online-judge-tools/template-generator)
int main()
{
#ifndef LOCAL
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif
    constexpr char endl = '\n';
    int64_t N, M;
    cin >> N >> M;
    auto ans = solveCase(N, M);
    cout << ans << endl;
    return 0;
}
#include "bits/stdc++.h"
#include<sstream>
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define NIL = -1;
#define all(x) x.begin(),x.end()
const ll INF = 1e9;
const long long inf = 1e18;
const ll INFL = 1e18;
const ll MOD = 1e9 + 7;
 
int digit(ll x) {
    int digits = 0;
 
    while(x > 0){
        x /= 10;
        digits++;
    }
 
    return digits;
}
 
ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}
 
bool is_prime(long long N){
    if (N == 1) return false;
    for (long long i = 2;i * i <= N;i++){
        if (N % i == 0) return false;
    }
    return true;
}
 
ll lcm(ll a,ll b){
    return ((a * b == 0)) ? 0 : (a / gcd(a,b) * b);
}
 
double DegreeToRadian(double degree){
    return degree * M_PI / 180.0;
}
 
long long modpow(long long a, long long b, long long m){
    long long ans = 1;
    while(b > 0){
        if (b % 2 == 1){
            ans *= a;
            ans %= m;
        }
        a *= a;
        a %= m;
        b /= 2;
    }
    return ans;
}

long long comb(long long x, long long y){
    int z;
    if (y == 0) return 1;
    else {
        z = modpow(x, y/2, MOD)*modpow(x, y/2, MOD)%MOD;
        if (y % 2 == 1) z = z*x%MOD;
        return z;
    }
}


vector<pair<long long, long long>> prime_fact(long long x){
    vector<pair<long long, long long>> res;
    for(int i = 2;i*i <= x;i++){
        if (x % i == 0){
            long long cnt = 0;
            while(x % i == 0){
                cnt++;
                x /= i;
            }
            res.push_back({i, cnt});
        }
    }
    if (x != 1){
        res.push_back({x, 1});
    }
    return res;
}

int64_t mod_inv(int64_t a, int64_t m){
    int64_t b = m, u = 1, v = 0;

    while(b){
        int64_t t = a/b;
        a -= t*b;
        swap(a, b);
        u -= t*v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;

    return u;
}


// {g, x, y}: ax + by = g
tuple<long long, long long, long long> extgcd(long long a, long long b){
    if (b == 0) return {a, 1, 0};
    long long g, x, y;
    tie(g, x, y) = extgcd(b, a % b);
    return {g, y, x - a/b*y};
}

int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

 
//////////////////////////////////////////////////////////////
long long n ,k;
struct matrix{
    long long value[55][55];
};

matrix multi(matrix &a, matrix &b){
    matrix c;
    for(int i = 1;i <= n;i++){
        for(int j = 1;j <= n;j++){
            c.value[i][j] = 0;
            for(int k = 1;k <= n;k++){
                c.value[i][j] += a.value[i][k]*b.value[k][j];
                c.value[i][j] %= MOD; 
            }
        }
    }

    return c;
}


int main(){
    int h , w;
    cin >> h >> w;
    vector<string> s(h);
    for(int i = 0;i < h;i++){
        cin >> s[i];
    }   
    int DX[4] = {0, 1, 0, 1};
    int DY[4] = {0, 0, 1, 1};
    int cnt = 0;
    int ans = 0;
    for(int i = 1;i < h;i++){
        for(int j = 0;j < w - 1;j++){
            cnt = 0;
            for(int k = 0;k < 4;k++){
                if (s[i - DY[k]][j + DX[k]] == '#') cnt++;
            }
            if (cnt == 1 || cnt == 3) ans++;
        }   
    }

    cout << ans << endl;
    return 0;
}