#include <bits/stdc++.h>
using namespace std;
char grid[405][405];
int mp[405][405];
int U[405][405], L[405][405], UL[405][405], UR[405][405];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    scanf("%s", grid[i] + 1);
    for (int j = 1; j <= m; ++j) mp[i][j] = (grid[i][j] == '0') ? 1 : 0;
  }
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) {
      U[i][j] = U[i - 1][j] + mp[i][j];
      L[i][j] = L[i][j - 1] + mp[i][j];
      UL[i][j] = UL[i - 1][j - 1] + mp[i][j];
    }
  for (int i = 1; i <= n; ++i)
    for (int j = m; j >= 1; --j) {
      UR[i][j] = UR[i - 1][j + 1] + mp[i][j];
    }
  int ans = 0;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j)
      if (mp[i][j]) {
        for (int d = 1; mp[i - d][j] && mp[i][j - d]; ++d)
          if (UR[i][j - d] - UR[i - d - 1][j + 1] == d + 1) ans++;
        for (int d = 1; mp[i + d][j] && mp[i][j + d]; ++d)
          if (UR[i + d][j] - UR[i - 1][j + d + 1] == d + 1) ans++;
        for (int d = 1; mp[i - d][j] && mp[i][j + d]; ++d)
          if (UL[i][j + d] - UL[i - d - 1][j - 1] == d + 1) ans++;
        for (int d = 1; mp[i + d][j] && mp[i][j - d]; ++d)
          if (UL[i + d][j] - UL[i - 1][j - d - 1] == d + 1) ans++;
        for (int d = 1; mp[i - d][j] && mp[i + d][j]; ++d)
          if (UR[i][j - d] - UR[i - d - 1][j + 1] == d + 1 &&
              UL[i + d][j] - UL[i - 1][j - d - 1] == d + 1)
            ans++;
        for (int d = 1; mp[i + d][j] && mp[i - d][j]; ++d)
          if (UL[i][j + d] - UL[i - d - 1][j - 1] == d + 1 &&
              UR[i + d][j] - UR[i - 1][j + d + 1] == d + 1)
            ans++;
        for (int d = 1; mp[i][j - d] && mp[i][j + d]; ++d)
          if (UR[i][j - d] - UR[i - d - 1][j + 1] == d + 1 &&
              UL[i][j + d] - UL[i - d - 1][j - 1] == d + 1)
            ans++;
        for (int d = 1; mp[i][j + d] && mp[i][j - d]; ++d)
          if (UR[i + d][j] - UR[i - 1][j + d + 1] == d + 1 &&
              UL[i + d][j] - UL[i - 1][j - d - 1] == d + 1)
            ans++;
      }
  printf("%d\n", ans);
  return 0;
}
