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

#define pb push_back
#define eb emplace_back
#define mk make_pair
#define fi first
#define se second
#define mset(a, b) memset(a, b, sizeof(a))
using ll = long long;
using pii = pair<int, int>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class Ty> Ty randint(Ty a, Ty b) { return uniform_int_distribution<Ty>(a, b)(rng); }

template<class T> void DBG(T&& x) { cerr << x << " "; }
template<class T, class...Args> void DBG(T&& x, Args&&... args) { DBG(x); DBG(args...); }
#define DBG(...) { cerr << "[" << #__VA_ARGS__ << "]: "; DBG(__VA_ARGS__); cerr << endl; }
template<class num> inline void rd(num& x) { cin >> x; }
template <class Ty, class... Args> inline void rd(Ty& x, Args&... args) { rd(x); rd(args...); }
template<class num> inline void print(num&& x) { cout << x; }
template <class Ty, class... Args> inline void print(Ty&& x, Args&&... args) { print(x); print(' '); print(args...); }
#define print(...) print(__VA_ARGS__), print('\n')

inline void run_test(int test_number) {
	int n, m; rd(n, m);
	vector<string> a(n);
	for (int i = 0; i < n; i++) rd(a[i]);

	int ans = 0;

	auto has = [&a](int i, int j) { return a[i][j] == '#'; };
	for (int i = 1; i + 1 < n; i++) {
		for (int j = 1; j + 1 < m; j++) {
			if (a[i][j] == '#') {

				ans += !has(i-1, j) && !has(i, j-1);
				ans += !has(i+1, j) && !has(i, j-1);
				ans += !has(i+1, j) && !has(i, j+1);
				ans += !has(i-1, j) && !has(i, j+1);
				ans += has(i-1, j) && has(i, j-1) && !has(i-1, j-1);
				ans += has(i+1, j) && has(i, j-1) && !has(i+1, j-1);
				ans += has(i+1, j) && has(i, j+1) && !has(i+1, j+1);
				ans += has(i-1, j) && has(i, j+1) && !has(i-1, j+1);
			}
		}
	}

	print(ans);
}

int main() {

//#ifndef LOCAL_PC
//	freopen("FILE.in", "r", stdin);
//#endif

	ios::sync_with_stdio(false); cin.tie(nullptr);
	int n_tests = 1;
	for (int i = 1; i <= n_tests; i++) run_test(i);
}
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    int H, W;
    cin >> H >> W;

    vector<string> S;
    for (int i = 0; i < H; i++) {
        string s;
        cin >> s;
        S.push_back(s);
    }

    int ans = 0;
    for (int h = 0; h < H  - 1; h++) {
        for (int w = 0; w < W - 1; w++) {
            int count = 0;
            for (int hp = 0; hp <=1; hp++) {
                for (int wp=0; wp <=1; wp++) {
                    if (S[h + hp][w + wp] == '#') count++;
                }
            }
            if (count == 1 || count == 3) {
                ans ++;
            }
        }

    }

    cout << ans << endl;

}

/*
5 5
.....
..#..
.###.
..#..
.....

*/

/*
5 6
......
..#...
.####.
..#...
......

*/
