#include <bits/stdc++.h>
using namespace std;
const int M = 500;
int a[M][M];
pair<int, int> nap[M][M][8];
char s[M];
int main() {
  int n, m, i, j, t, ans;
  scanf("%d%d", &n, &m);
  for (i = 0; i < n; i++) {
    scanf("%s", s);
    for (j = 0; j < m; j++) a[i + 1][j + 1] = s[j] - '0';
  }
  for (i = 0; i <= n + 1; i++) {
    a[i][0] = 1;
    a[i][m + 1] = 1;
  }
  for (i = 0; i <= m + 1; i++) {
    a[0][i] = 1;
    a[n + 1][i] = 1;
  }
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) {
      if (a[i][j] == 0) {
        if (a[i - 1][j - 1] == 0)
          nap[i][j][0] = nap[i - 1][j - 1][0];
        else
          nap[i][j][0] = make_pair(i - 1, j - 1);
        if (a[i - 1][j] == 0)
          nap[i][j][1] = nap[i - 1][j][1];
        else
          nap[i][j][1] = make_pair(i - 1, j);
      }
    }
  for (i = 1; i <= n; i++)
    for (j = m; j > 0; j--) {
      if (a[i][j] == 0) {
        if (a[i - 1][j + 1] == 0)
          nap[i][j][2] = nap[i - 1][j + 1][2];
        else
          nap[i][j][2] = make_pair(i - 1, j + 1);
        if (a[i][j + 1] == 0)
          nap[i][j][3] = nap[i][j + 1][3];
        else
          nap[i][j][3] = make_pair(i, j + 1);
      }
    }
  for (i = n; i > 0; i--)
    for (j = m; j > 0; j--) {
      if (a[i][j] == 0) {
        if (a[i + 1][j + 1] == 0)
          nap[i][j][4] = nap[i + 1][j + 1][4];
        else
          nap[i][j][4] = make_pair(i + 1, j + 1);
        if (a[i + 1][j] == 0)
          nap[i][j][5] = nap[i + 1][j][5];
        else
          nap[i][j][5] = make_pair(i + 1, j);
      }
    }
  for (i = n; i > 0; i--)
    for (j = 1; j <= m; j++) {
      if (a[i][j] == 0) {
        if (a[i + 1][j - 1] == 0)
          nap[i][j][6] = nap[i + 1][j - 1][6];
        else
          nap[i][j][6] = make_pair(i + 1, j - 1);
        if (a[i][j - 1] == 0)
          nap[i][j][7] = nap[i][j - 1][7];
        else
          nap[i][j][7] = make_pair(i, j - 1);
      }
    }
  ans = 0;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++)
      if (a[i][j] == 0) {
        for (t = j - 1; t > nap[i][j][7].second; t--)
          if (nap[i][t][2].second > j && nap[i][j][1].first < i - (j - t))
            ans++;
        for (t = j + 1; t < nap[i][j][3].second; t++)
          if (nap[i][t][0].second < j && nap[i][j][1].first < i - (t - j))
            ans++;
        for (t = j - 1; t > nap[i][j][7].second; t--)
          if (nap[i][t][4].second > j && nap[i][j][5].first > i + (j - t))
            ans++;
        for (t = j + 1; t < nap[i][j][3].second; t++)
          if (nap[i][t][6].second < j && nap[i][j][5].first > i + (t - j))
            ans++;
        for (t = j - 1; t > nap[i][j][0].second; t--)
          if (nap[i - (j - t)][t][3].second > 2 * j - t &&
              nap[i][j][2].second > 2 * j - t)
            ans++;
        for (t = j - 1; t > nap[i][j][0].second; t--)
          if (nap[i - (j - t)][t][5].first > i + j - t &&
              nap[i][j][6].second < t)
            ans++;
        for (t = j + 1; t < nap[i][j][4].second; t++)
          if (nap[i + (t - j)][t][7].second < 2 * j - t &&
              nap[i][j][6].second < 2 * j - t)
            ans++;
        for (t = j + 1; t < nap[i][j][4].second; t++)
          if (nap[i + (t - j)][t][1].first < i - (t - j) &&
              nap[i][j][2].second > t)
            ans++;
      }
  printf("%d", ans);
  return 0;
}
