#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using pii = pair<int, int>;
pii getSquarePoint(int n, int h, int w, int h2, int w2) {
  pii ret;
  n %= ((h + w) * 2);
  if (n < w) {
    return make_pair(h2 + 0, w2 + n);
  } else if (n < w + h) {
    return make_pair(h2 + n - w, w2 + w);
  } else if (n < w + h + w) {
    return make_pair(h2 + h, w2 + w - (n - w - h));
  } else {
    return make_pair(h2 + h - (n - w - h - w), w2 + 0);
  }
}
int main() {
  int H;
  scanf("%d", &(H));
  getchar();
  ;
  int W;
  scanf("%d", &(W));
  getchar();
  ;
  vector<vector<char>> board(H, vector<char>(W));
  for (int h = 0; h < (H); ++h) {
    for (int w = 0; w < (W); ++w) {
      board[h][w] = (getchar() == '#');
    }
    getchar();
  }
  ll result = 0;
  for (int h = (1); h < (H); ++h) {
    for (int w = 3 - h % 3; w < W; w += 3) {
      for (int h2 = 0; h2 < (H - h); ++h2) {
        for (int w2 = 0; w2 < (W - w); ++w2) {
          if (w * 2 == h) {
            if (board[h2][w2] && board[h2 + h][w2] && board[h2 + h / 2][w2 + w])
              ++result;
            if (board[h2][w2 + w] && board[h2 + h][w2 + w] &&
                board[h2 + h / 2][w2])
              ++result;
          } else if (h * 2 == w) {
            if (board[h2][w2] && board[h2][w2 + w] && board[h2 + h][w2 + w / 2])
              ++result;
            if (board[h2 + h][w2] && board[h2 + h][w2 + w] &&
                board[h2][w2 + w / 2])
              ++result;
          } else {
            const int M = (h + w) / 3 * 2;
            for (int m : {0, w, w + h, w + h + w}) {
              const auto a0 = getSquarePoint(m + M * 0, h, w, h2, w2);
              const auto a1 = getSquarePoint(m + M * 1, h, w, h2, w2);
              const auto a2 = getSquarePoint(m + M * 2, h, w, h2, w2);
              if (board[a0.first][a0.second] && board[a1.first][a1.second] &&
                  board[a2.first][a2.second] &&
                  (a0.first == h2 || a1.first == h2 || a2.first == h2) &&
                  (a0.first == h2 + h || a1.first == h2 + h ||
                   a2.first == h2 + h) &&
                  (a0.second == w2 || a1.second == w2 || a2.second == w2) &&
                  (a0.second == w2 + w || a1.second == w2 + w ||
                   a2.second == w2 + w))
                ++result;
            }
          }
        }
      }
    }
  }
  cout << result << endl;
}
