#include <bits/stdc++.h>
using namespace std;
int n, m, res;
int mat[405][405];
int cnt[405][405][4];
bool valid(int x1, int y1, int x2, int y2) {
  int num = 2;
  if (x1 == x2) num = 1;
  if (y1 == y2) num = 0;
  if (x1 + y1 == x2 + y2) num = 3;
  return cnt[x1][y1][num] == cnt[x2][y2][num];
}
void check(int x1, int y1, int x2, int y2, int x3, int y3) {
  if (x1 < 1 || y1 < 1 || x2 < 1 || y2 < 1 || x3 < 1 || y3 < 1) return;
  if (x1 > n || y1 > m || x2 > n || y2 > m || x3 > n || y3 > m) return;
  if (mat[x1][y1] || mat[x2][y2] || mat[x3][y3]) return;
  if (!valid(x1, y1, x2, y2)) return;
  if (!valid(x2, y2, x3, y3)) return;
  if (!valid(x1, y1, x3, y3)) return;
  res++;
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      char c;
      cin >> c;
      mat[i][j] = (c - '0');
      cnt[i][j][0] = cnt[i - 1][j][0] + mat[i][j];
      cnt[i][j][1] = cnt[i][j - 1][1] + mat[i][j];
      cnt[i][j][2] = cnt[i - 1][j - 1][2] + mat[i][j];
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = m; j >= 1; j--) {
      cnt[i][j][3] = cnt[i - 1][j + 1][3] + mat[i][j];
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      for (int k = 1; k <= min(n, m); k++) {
        check(i, j, i + k, j, i, j + k);
        check(i, j, i - k, j, i, j + k);
        check(i, j, i + k, j, i, j - k);
        check(i, j, i - k, j, i, j - k);
        check(i - k, j, i, j + k, i, j - k);
        check(i + k, j, i, j + k, i, j - k);
        check(i + k, j, i - k, j, i, j - k);
        check(i + k, j, i - k, j, i, j + k);
      }
    }
  }
  cout << res << '\n';
  return 0;
}
