#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

template <typename T1, typename T2>
string print_iterable(T1 begin_iter, T2 end_iter, int counter) {
    bool done_something = false;
    stringstream res;
    res << "[";
    for (; begin_iter != end_iter and counter; ++begin_iter) {
        done_something = true;
        counter--;
        res << *begin_iter << ", ";
    }
    string str = res.str();
    if (done_something) {
        str.pop_back();
        str.pop_back();
    }
    str += "]";
    return str;
}

vector<int> SortIndex(int size, std::function<bool(int, int)> compare) {
    vector<int> ord(size);
    for (int i = 0; i < size; i++) ord[i] = i;
    sort(ord.begin(), ord.end(), compare);
    return ord;
}

template <typename T>
bool MinPlace(T& a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool MaxPlace(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <typename Container>
int SZ(const Container& S) { return S.size(); }

template <typename S, typename T>
ostream& operator <<(ostream& out, const pair<S, T>& p) {
    out << "{" << p.first << ", " << p.second << "}";
    return out;
}

template <typename T>
ostream& operator <<(ostream& out, const vector<T>& v) {
    out << "[";
    for (int i = 0; i < (int)v.size(); i++) {
        out << v[i];
        if (i != (int)v.size()-1) out << ", ";
    }
    out << "]";
    return out;
}

#if DEBUG && !ONLINE_JUDGE
    ifstream input_from_file("input.txt");
    #define cin input_from_file

    #define dbg_var(x) clog << #x  << ": " << x << endl;
    #define dbg_array(x, len) clog << #x << ": " << print_iterable(x, x+len, -1) << endl;
#else
    #define dbg_var(x)
    #define dbg_array(x, len)
#endif

///////////////////////////////////////////////////////////////////////////
//////////////////// DO NOT TOUCH BEFORE THIS LINE ////////////////////////
///////////////////////////////////////////////////////////////////////////

const int MAXN = 310;
int mat[MAXN][MAXN];
int prec[MAXN][MAXN];
int H, W;

int ut(int x, int y) {
    // cout << x << " " << y << endl;
    int d = max(0, max(x-H, 1-y));
    x -= d, y += d;
    // cout << x << " " << y << endl;
    return (x > 0 and y <= W)?prec[x][y]:0;
}

LL solve(int Z) {
    LL res = 0;
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            prec[i][j] = prec[i-1][j+1] + mat[i][j];
        }
    }

    for (int a = 1; a <= H+W; a++) {
        int mini = max(1, a-W);
        int maxi = min(H, a-1);
        for (int i1 = mini; i1 <= maxi; i1++) {
            int j1 = a-i1;
            if (!mat[i1][j1]) continue;
            for (int i2 = i1+1; i2 <= maxi; i2++) {
                int j2 = a-i2;
                if (!mat[i2][j2]) continue;
                int d = (i2-i1 + j1-j2)/2;
                // cout << i1 << " " << j1 << " " << i2 << " " << j2 << endl;
                res += ut(i2+d-1+Z, j2+d+1-Z) - ut(i1+d-Z, j1+d+Z);
                // dbg_var(res);
                res += ut(i2-d-1+Z, j2-d+1-Z) - ut(i1-d-Z, j1-d+Z);
                // dbg_var(res);
            }
        }
    }
    return res;
}

LL slow_sol() {
    LL res = 0;
    for (int i1 = 1; i1 <= H; i1++) for (int i2 = 1; i2 <= H; i2++) for (int i3 = 1; i3 <= H; i3++) {
        for (int j1 = 1; j1 <= W; j1++) for (int j2 = 1; j2 <= W; j2++) for (int j3 = 1; j3 <= W; j3++) {
            if (i1 == i2 and j1 == j2) continue;
            if (!mat[i1][j1] or !mat[i2][j2] or !mat[i3][j3]) continue;
            int d1 = abs(i1-i2) + abs(j1-j2);
            int d2 = abs(i1-i3) + abs(j1-j3);
            int d3 = abs(i3-i2) + abs(j3-j2);
            if (d1 == d2 and d2 == d3) res++;
        }
    }
    return res/6;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); // Remove in problems with online queries!
    cin >> H >> W;
    for (int i = 1; i <= H; i++) {
        string s;
        cin >> s;
        for (int j = 1; j <= W; j++) mat[i][j] = s[j-1] == '#';
    }
    LL ris1 = solve(1);
    for (int i = 1; 2*i <= H; i++) {
        for (int j = 1; j <= W; j++) swap(mat[i][j], mat[H+1-i][j]);
    }
    LL ris2 = solve(0);
    // dbg_var(ris1);
    cout << ris1 + ris2 << "\n";
}


Measured memory_bytes: 1024