#include <bits/stdc++.h>
using namespace std;
int len[8][500][500];
int arr[500][500];
int main() {
  cin.sync_with_stdio(0);
  int ans = 0, n, m;
  string mystr;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> mystr;
    for (int j = 1; j <= m; j++) {
      if (mystr[j - 1] == '0') arr[i][j] = 1;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (arr[i][j]) {
        len[0][i][j] = len[0][i][j - 1] + 1;
        len[1][i][j] = len[1][i - 1][j - 1] + 1;
        len[2][i][j] = len[2][i - 1][j] + 1;
      }
    }
  }
  for (int i = n; i > 0; i--) {
    for (int j = m; j > 0; j--) {
      if (arr[i][j]) {
        len[4][i][j] = len[4][i][j + 1] + 1;
        len[5][i][j] = len[5][i + 1][j + 1] + 1;
        len[6][i][j] = len[6][i + 1][j] + 1;
      }
    }
  }
  for (int i = n; i > 0; i--) {
    for (int j = 1; j <= m; j++) {
      if (arr[i][j]) {
        len[7][i][j] = len[7][i + 1][j - 1] + 1;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = m; j > 0; j--) {
      if (arr[i][j]) {
        len[3][i][j] = len[3][i - 1][j + 1] + 1;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (arr[i][j]) {
        arr[i][j]--;
        for (int k = 1; k < min(len[1][i][j], len[3][i][j]); k++) {
          if (len[4][i - k][j - k] >= 2 * k) {
            ans++;
            arr[i][j]++;
          }
        }
        for (int k = 1; k < min(len[2][i][j], len[4][i][j]); k++) {
          if (len[5][i - k][j] >= k) {
            arr[i][j]++;
            ans++;
          }
        }
        for (int k = 1; k < min(len[3][i][j], len[5][i][j]); k++) {
          if (len[6][i - k][j + k] >= 2 * k) {
            arr[i][j]++;
            ans++;
          }
        }
        for (int k = 1; k < min(len[4][i][j], len[6][i][j]); k++) {
          if (len[7][i][j + k] >= k) {
            arr[i][j]++;
            ans++;
          }
        }
        for (int k = 1; k < min(len[5][i][j], len[7][i][j]); k++) {
          if (len[0][i + k][j + k] >= 2 * k) {
            ans++;
            arr[i][j]++;
          }
        }
        for (int k = 1; k < min(len[6][i][j], len[0][i][j]); k++) {
          if (len[1][i + k][j] >= k) {
            arr[i][j]++;
            ans++;
          }
        }
        for (int k = 1; k < min(len[7][i][j], len[1][i][j]); k++) {
          if (len[2][i + k][j - k] >= 2 * k) {
            arr[i][j]++;
            ans++;
          }
        }
        for (int k = 1; k < min(len[0][i][j], len[2][i][j]); k++) {
          if (len[3][i][j - k] >= k) {
            arr[i][j]++;
            ans++;
          }
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
