#include <bits/stdc++.h>
using namespace std;
const int N = 402;
int color[N][N];
int R[N][N];
int C[N][N];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  string s[401];
  for (int i = 0; i < n; i++) cin >> s[i];
  for (int i = 1; i < n + 1; i++)
    for (int j = 1; j < m + 1; j++) {
      color[i][j] = s[i - 1][j - 1] - '0';
      R[i][j] = R[i][j - 1] + s[i - 1][j - 1] - '0';
      C[i][j] = C[i - 1][j] + s[i - 1][j - 1] - '0';
    }
  long long int ans1 = 0;
  long long int ans2 = 0;
  for (int i = 1; i < n + 1; i++)
    for (int j = 1; j < m + 1; j++)
      if (!color[i][j]) {
        int left, right, st;
        left = right = st = 1;
        for (int k = 1; k + i <= n; k++) {
          int cnt = 0;
          if (left && j - k > 0 && R[i + k][j] - R[i + k][j - k - 1] == 0) {
            if (st) ans1++;
            cnt++;
          }
          if (right && j + k <= m && R[i + k][j + k] - R[i + k][j - 1] == 0) {
            if (st) ans1++;
            cnt++;
          }
          if (cnt == 2) ans2++;
          if (j - k > 0 && color[i + k][j - k]) left = 0;
          if (j + k <= m && color[i + k][j + k]) right = 0;
          if (color[i + k][j]) st = 0;
          if (!(left | right)) break;
        }
        left = right = st = 1;
        for (int k = 1; i - k > 0; k++) {
          int cnt = 0;
          if (left && j - k > 0 && R[i - k][j] - R[i - k][j - k - 1] == 0) {
            if (st) ans1++;
            cnt++;
          }
          if (right && j + k <= m && R[i - k][j + k] - R[i - k][j - 1] == 0) {
            if (st) ans1++;
            cnt++;
          }
          if (cnt == 2) ans2++;
          if (j - k > 0 && color[i - k][j - k]) left = 0;
          if (j + k <= m && color[i - k][j + k]) right = 0;
          if (color[i - k][j]) st = 0;
          if (!(left | right)) break;
        }
        left = right = st = 1;
        for (int k = 1; k + j <= m; k++) {
          int cnt = 0;
          if (left && i - k > 0 && C[i][j + k] - C[i - k - 1][j + k] == 0) {
            if (st) ans1++;
            cnt++;
          }
          if (right && i + k <= n && C[i + k][j + k] - C[i - 1][j + k] == 0) {
            if (st) ans1++;
            cnt++;
          }
          if (cnt == 2) ans2++;
          if (i - k > 0 && color[i - k][j + k]) left = 0;
          if (i + k <= n && color[i + k][j + k]) right = 0;
          if (color[i][j + k]) st = 0;
          if (!(left | right)) break;
        }
        left = right = st = 1;
        for (int k = 1; j - k > 0; k++) {
          int cnt = 0;
          if (left && i - k > 0 && C[i][j - k] - C[i - k - 1][j - k] == 0) {
            if (st) ans1++;
            cnt++;
          }
          if (right && i + k <= n && C[i + k][j - k] - C[i - 1][j - k] == 0) {
            if (st) ans1++;
            cnt++;
          }
          if (cnt == 2) ans2++;
          if (i - k > 0 && color[i - k][j - k]) left = 0;
          if (i + k <= n && color[i + k][j - k]) right = 0;
          if (color[i][j - k]) st = 0;
          if (!(left | right)) break;
        }
      }
  assert(ans1 % 2 == 0);
  cout << ans1 / 2 + ans2 << endl;
  return 0;
}
