#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
double dot(complex<double> a, complex<double> b) {
	return a.real() * b.real() + a.imag() * b.imag();
}
double gyaku_dot(complex<double> a, complex<double> b) {
	return a.real() * b.imag() - a.imag() * b.real();
}
double leng(complex<double> a) {
	return sqrt(a.real() * a.real() + a.imag() * a.imag());
}
double angles(complex<double> a, complex<double> b) {
	double cosine = dot(a, b) / (leng(a) * leng(b));
	double sine = gyaku_dot(a, b) / (leng(a) * leng(b));
	double kaku = acos(cosine);
	if (sine <= 0) {
		kaku = 2 * Ma_PI - kaku;
	}
	return kaku;
}
vector<int> convex_hull(vector<complex<double>> a) {
	vector<int> ans;
	double now_minnest = a[0].real();
	int now_itr = 0;
	REP(i, a.size()) {
		if (now_minnest > a[i].real()) {
			now_minnest = a[i].real();
			now_itr = i;
		}
	}
	ans.push_back(now_itr);
	complex<double> ba(0, 1);
	while (true) {
		int now_go = 0;
		double now_min = 0;
		int starter = ans[ans.size() - 1];
		for (int i = 0; i < a.size(); ++i) {
			if (i != starter) {
				double goa = angles(ba, a[i] - a[starter]);
				if (goa > now_min) {
					now_min = goa;
					now_go = i;
				}
			}
		}
		if (now_go == ans[0]) break;
		ans.push_back(now_go);
		ba = complex<double>(a[now_go] - a[starter]);
	}
	return ans;
}
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
long long dp[3000][3000] = {};
long long second_dp[3000][3000];
vector<int> grids[3000];
vector<int> second_grids[3000];
int main() {
#define int long long
	iostream::sync_with_stdio(false);
	int h, w;
	cin >> h >> w;
	REP(i, h) {
		string a;
		cin >> a;
		REP(q, a.length()) {
			if (a[q] == '#') {
				dp[i+q][q]++;
				grids[i + q].push_back(q);
			}
		}
		reverse(a.begin(), a.end());
		REP(q, a.length()) {
			if (a[q] == '#') {
				second_dp[i + q][q]++;
				second_grids[i + q].push_back(q);
			}
		}
	}
	for (int i = 0; i < 1000; ++i) {
		for (int q = 1; q < 1000; ++q) {
			dp[i][q] += dp[i][q - 1];
			second_dp[i][q] += second_dp[i][q - 1];
		}
	}
	long long ans = 0;
	for (int i = 0; i <= 1000; ++i) {
		sort(grids[i].begin(), grids[i].end());
		for (int q = 0; q < grids[i].size(); ++q) {
			for (int j = q + 1; j < grids[i].size(); ++j) {
				int diff = grids[i][j] - grids[i][q];
				int next_i = i - 2 * diff;
				if (next_i >= 0) {
					if (grids[i][j] - diff >= 1) {
						ans += dp[next_i][grids[i][j] - diff-1];
						int now = grids[i][q] - diff;
						if (now >= 0) {
							ans -= dp[next_i][now];
						}
					}
				}
				next_i = i + 2 * diff;
				if (next_i >= 0) {
					if (grids[i][j] + diff >= 1) {
						ans += dp[next_i][grids[i][j] + diff - 1];
						int now = grids[i][q] + diff;
						if (now >= 0) {
							ans -= dp[next_i][now];
						}
					}
				}
			}
		}
	}
	for (int i = 0; i <= 1000; ++i) {
		sort(second_grids[i].begin(), second_grids[i].end());
		for (int q = 0; q < second_grids[i].size(); ++q) {
			for (int j = q + 1; j < second_grids[i].size(); ++j) {
				int diff = second_grids[i][j] - second_grids[i][q];
				int next_i = i - 2 * diff;
				if (next_i >= 0) {
					ans += second_dp[next_i][second_grids[i][j] - diff];
					int now = second_grids[i][q] - diff - 1;
					if (now >= 0) {
						ans -= second_dp[next_i][now];
					}
				}
				next_i = i + 2 * diff;
				if (next_i >= 0) {
					ans += second_dp[next_i][second_grids[i][j] + diff];
					int now = second_grids[i][q] + diff - 1;
					if (now >= 0) {
						ans -= second_dp[next_i][now];
					}
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 49656