#include <bits/stdc++.h>
using namespace std;
char s[405][405];
int n, m, i, j, k, sum1[405][405], sum2[405][405], sum3[405][405],
    sum4[405][405];
long long ans;
int work(int a, int b, int c) {
  if (b < 0 || c < 0 || b >= n || c >= m) return 0;
  if (a == 1) return sum1[b][c];
  if (a == 2) return sum2[b][c];
  if (a == 3) return sum3[b][c];
  return sum4[b][c];
}
int main() {
  scanf("%d%d", &n, &m);
  for (i = 0; i < n; i++) scanf("%s", s[i]);
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++) {
      if (i != 0 && j != 0) sum1[i][j] = sum1[i - 1][j - 1];
      sum1[i][j] += (s[i][j] == '1');
    }
  for (i = 0; i < n; i++)
    for (j = m - 1; j >= 0; j--) {
      if (i != 0 && j != m - 1) sum2[i][j] = sum2[i - 1][j + 1];
      sum2[i][j] += (s[i][j] == '1');
    }
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++) {
      if (i != 0) sum3[i][j] = sum3[i - 1][j];
      sum3[i][j] += (s[i][j] == '1');
    }
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++) {
      if (j != 0) sum4[i][j] = sum4[i][j - 1];
      sum4[i][j] += (s[i][j] == '1');
    }
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++)
      if (s[i][j] == '0') {
        for (k = i + 1; k < n; k++)
          if (k - i + j >= m || s[k][j] == '1' || s[i][k - i + j] == '1')
            break;
          else if (work(2, k, j) - work(2, i - 1, k - i + j + 1) == 0)
            ans++;
        for (k = i + 1; k < n; k++)
          if (j - (k - i) < 0 || s[k][j] == '1' || s[i][j - (k - i)] == '1')
            break;
          else if (work(1, k, j) - work(1, i - 1, j - (k - i) - 1) == 0)
            ans++;
        for (k = i - 1; k >= 0; k--)
          if (j + (k - i) < 0 || s[k][j] == '1' || s[i][j + (k - i)] == '1')
            break;
          else if (work(2, i, j + (k - i)) - work(2, k - 1, j + 1) == 0)
            ans++;
        for (k = i - 1; k >= 0; k--)
          if (j + (i - k) >= m || s[k][j] == '1' || s[i][i + j - k] == '1')
            break;
          else if (work(1, i, i + j - k) - work(1, k - 1, j - 1) == 0)
            ans++;
        for (k = i - 1; k >= 0; k--)
          if (j + (i - k) >= m || j - (i - k) < 0)
            break;
          else if (s[k][j + (k - i)] == '1' || s[k][j - (k - i)] == '1')
            break;
          else if (work(4, k, j - (k - i)) - work(4, k, j + (k - i) - 1) == 0)
            ans++;
        for (k = i + 1; k < n; k++)
          if (j + (k - i) >= m || j - (k - i) < 0)
            break;
          else if (s[k][j + (i - k)] == '1' || s[k][j - (i - k)] == '1')
            break;
          else if (work(4, k, j + (k - i)) - work(4, k, j - (k - i) - 1) == 0)
            ans++;
        for (k = j - 1; k >= 0; k--)
          if (i - (j - k) < 0 || i + (j - k) >= n)
            break;
          else if (s[i - (j - k)][k] == '1' || s[i + (j - k)][k] == '1')
            break;
          else if (work(3, i + (j - k), k) - work(3, i - (j - k) - 1, k) == 0)
            ans++;
        for (k = j + 1; k < m; k++)
          if (i - (k - j) < 0 || i + (k - j) >= n)
            break;
          else if (s[i - (k - j)][k] == '1' || s[i + (k - j)][k] == '1')
            break;
          else if (work(3, i - (j - k), k) - work(3, i + (j - k) - 1, k) == 0)
            ans++;
      }
  cout << ans;
  return 0;
}
