#include <bits/stdc++.h>
using namespace std;
const int SIZE = 411;
string s[822];
int dp[4][822][822];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = (1); i <= (n); ++i) cin >> s[i];
  memset(dp, 0, sizeof(dp));
  for (int i = (1); i <= (n); ++i)
    for (int j = (1); j <= (m); ++j) {
      if (s[i][j - 1] == '0') {
        dp[0][i][j] = dp[0][i][j - 1] + 1;
        dp[1][i][j] = dp[1][i - 1][j - 1] + 1;
        dp[2][i][j] = dp[2][i - 1][j] + 1;
        dp[3][i][j] = dp[3][i - 1][j + 1] + 1;
      }
    }
  int an = 0;
  for (int i = (1); i <= (n); ++i)
    for (int j = (1); j <= (m); ++j) {
      for (int k = (1); k <= (i); ++k) {
        if (dp[1][i][j] >= k + 1 && dp[3][i][j] >= k + 1 &&
            dp[0][i - k][j + k] >= 2 * k + 1)
          an++;
      }
      for (int k = (1); k <= (SIZE); ++k) {
        if (dp[0][i][j + k] >= k + 1 && dp[2][i][j] >= k + 1 &&
            dp[1][i][j + k] >= k + 1)
          an++;
      }
      for (int k = (1); k <= (SIZE); ++k) {
        if (dp[1][i + k][j + k] >= k + 1 && dp[2][i + k][j + k] >= k * 2 + 1 &&
            dp[3][i][j] >= k + 1)
          an++;
      }
      for (int k = (1); k <= (SIZE); ++k) {
        if (dp[2][i + k][j] >= k + 1 && dp[0][i][j + k] >= k + 1 &&
            dp[3][i + k][j] >= k + 1)
          an++;
      }
      for (int k = (1); k <= (j); ++k) {
        if (dp[3][i + k][j - k] >= k + 1 && dp[0][i + k][j + k] >= 2 * k + 1 &&
            dp[1][i + k][j + k] >= k + 1)
          an++;
      }
      for (int k = (1); k <= (SIZE); ++k) {
        if (dp[2][i + k][j] >= k + 1 && dp[1][i + k][j] >= k + 1 &&
            dp[0][i][j] >= k + 1)
          an++;
      }
      for (int k = (1); k <= (j); ++k) {
        if (dp[2][i + k][j - k] >= 2 * k + 1 && dp[3][i + k][j - k] >= k + 1 &&
            dp[1][i][j] >= k + 1)
          an++;
      }
      for (int k = (1); k <= (j); ++k) {
        if (dp[0][i][j] >= k + 1 && dp[2][i][j] >= k + 1 &&
            dp[3][i][j - k] >= k + 1)
          an++;
      }
    }
  cout << an;
  return 0;
}
