#include <random>

#include "bits/stdc++.h"

using namespace std;

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int h, w;
  cin >> h >> w;
  vector<string> s(h + 2, string(w + 2, '.'));
  for (int i = 1; i <= h; i++) {
    string t;
    cin >> t;
    for (int j = 0; j < w; j++) {
      if (t[j] == '#') s[i][j + 1] = '#';
    }
  }
  vector<vector<int>> left(h + 2, vector<int>(w + 2)),
      right(h + 2, vector<int>(w + 2));
  for (int i = 1; i <= h + 1; i++) {
    for (int j = 0; j <= w + 1; j++) {
      if (j != w + 1) left[i][j] = left[i - 1][j + 1];
      if (j) right[i][j] = right[i - 1][j - 1];
      if (s[i][j] == '#') {
        left[i][j]++;
        right[i][j]++;
      }
    }
    // printv(left[i]);
  }
  ll ans = 0;
  int n = max(h, w);
  int dx[4] = {1, 0, -1, 0}, dy[4] = {0, -1, 0, 1};
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      for (int len = 1; len <= n; len++) {
        int cnt = 0;
        for (int k = 0; k < 4; k++) {
          int nx = i + len * dx[k], ny = j + len * dy[k];
          if (nx < 1 || h < nx || ny < 1 || w < ny) continue;
          if (s[nx][ny] == '#') cnt++;
        }
        if (cnt == 3) ans += 1;
        if (cnt == 4) ans += 4;
      }
    }
  }
  // cout << ans << endl;
  auto calc = [&](int x1, int y1, int x2, int y2) {
    int difx = abs(x1 - x2), dify = abs(y1 - y2);
    assert(difx == dify);
    if (x1 > x2) {
      swap(x1, x2);
      swap(y1, y2);
    }
    if (y1 <= y2) {
      if (x1 < 0) {
        y1 += -x1;
        x1 = 0;
      }
      if (y1 < 0) {
        x1 += -y1;
        y1 = 0;
      }
      if (h + 1 < x2) {
        y2 -= x2 - h - 1;
        x2 = h + 1;
      }
      if (w + 1 < y2) {
        x2 -= y2 - w - 1;
        y2 = w + 1;
      }
    } else {
        if(x1 < 0){
            y1 += x1;
            x1 = 0;
        }
        if(w + 1 < y1){
            x1 += y1 - w - 1;
            y1 = w + 1;
        }
        if(h + 1 < x2){
            y2 += x2 - h - 1;
            x2 = h + 1;
        }
        if(y2 < 0){
            x2 += y2;
            y2 = 0;
        }
    }
    if (x1 < 0 || h + 1 < x1 || y1 < 0 || w + 1 < y1) return 0;
    if (x2 < 0 || h + 1 < x2 || y2 < 0 || w + 1 < y2) return 0;
    if (y1 <= y2) {
      auto ret = right[x2][y2] - right[x1][y1];
      if (s[x2][y2] == '#') ret--;
      return ret;
    }
    auto ret = left[x2][y2] - left[x1][y1];
    if (s[x2][y2] == '#') ret--;
    return ret;
  };
  for (int x = 1; x <= h; x++) {
    for (int y = 1; y <= w; y++) {
      for (int dir = 0; dir < 4; dir++) {
        int d = dir, nd = (dir + 1) % 4;
        int d3 = (dir + 2) % 4, d4 = (dir + 3) % 4;
        for (int len = 1; len <= n; len++) {
          int nx1 = x + len * dx[d], ny1 = y + len * dy[d];
          int nx2 = x + len * dx[nd], ny2 = y + len * dy[nd];
          if (nx1 < 1 || h < nx1 || ny1 < 1 || w < ny1) continue;
          if (nx2 < 1 || h < nx2 || ny2 < 1 || w < ny2) continue;
          if (s[nx1][ny1] == '.' || s[nx2][ny2] == '.') continue;
          int nx3 = x + len * dx[d3], ny3 = y + len * dy[d3];
          int nx4 = x + len * dx[d4], ny4 = y + len * dy[d4];
          ans += calc(nx3, ny3, nx4, ny4);
        }
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 4028