#include <bits/stdc++.h>
using namespace std;
char ar[1000][1000];
int a1[1000][1000], a2[1000][1000], ud[2000][2000], lr[1000][1000];
int n, m, i, j, k, cnt, r1, r2, r3, r4, m1, m2, m3, m4;
int main() {
  scanf("%d %d", &n, &m);
  for (i = 1; i <= n; i++) scanf("%s", ar[i] + 1);
  for (i = 0; i <= n; i++) {
    for (j = 0; j <= m; j++) {
      if (ar[i + 1][j + 1] == '0')
        a1[i + 1][j + 1] = a1[i][j];
      else
        a1[i + 1][j + 1] = a1[i][j] + 1;
    }
  }
  for (i = n + 1; i >= 1; i--) {
    for (j = 0; j <= m; j++) {
      if (ar[i - 1][j + 1] == '0')
        a2[i - 1][j + 1] = a2[i][j];
      else
        a2[i - 1][j + 1] = a2[i][j] + 1;
    }
  }
  for (i = 0; i <= n; i++) {
    for (j = 0; j <= m; j++) {
      if (ar[i][j + 1] == '0')
        lr[i][j + 1] = lr[i][j];
      else
        lr[i][j + 1] = lr[i][j] + 1;
    }
  }
  for (i = 0; i <= n; i++) {
    for (j = 0; j <= m; j++) {
      if (ar[i + 1][j] == '0')
        ud[i + 1][j] = ud[i][j];
      else
        ud[i + 1][j] = ud[i][j] + 1;
    }
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      k = 1;
      while (ar[i][j] == '0' &&
             ((i + k) <= n || i - k > 0 || j + k <= m || j - k > 0)) {
        if (i + k <= n && j + k <= m) {
          if (ar[i + k][j] == '0' && ar[i][j + k] == '0' && ar[i][j] == '0' &&
              abs(a2[i + k][j] - a2[i][j + k]) == 0 &&
              abs(ud[i][j] - ud[i + k][j]) == 0 &&
              abs(lr[i][j] - lr[i][j + k]) == 0) {
            cnt++;
          }
        }
        if (i + k <= n && j - k > 0) {
          if (ar[i + k][j] == '0' && ar[i][j - k] == '0' && ar[i][j] == '0' &&
              abs(a1[i + k][j] - a1[i][j - k]) == 0 &&
              abs(ud[i][j] - ud[i + k][j]) == 0 &&
              abs(lr[i][j] - lr[i][j - k]) == 0) {
            cnt++;
          }
        }
        if (i - k > 0 && j + k <= m) {
          if (ar[i - k][j] == '0' && ar[i][j + k] == '0' && ar[i][j] == '0' &&
              abs(a1[i - k][j] - a1[i][j + k]) == 0 &&
              abs(ud[i][j] - ud[i - k][j]) == 0 &&
              abs(lr[i][j] - lr[i][j + k]) == 0) {
            cnt++;
          }
        }
        if (i - k > 0 && j - k > 0) {
          if (ar[i - k][j] == '0' && ar[i][j - k] == '0' && ar[i][j] == '0' &&
              abs(a2[i - k][j] - a2[i][j - k]) == 0 &&
              abs(ud[i][j] - ud[i - k][j]) == 0 &&
              abs(lr[i][j] - lr[i][j - k]) == 0) {
            cnt++;
          }
        }
        if (i + k <= n && j + k <= m && j - k > 0) {
          if (ar[i + k][j] == '0' && ar[i][j + k] == '0' &&
              ar[i][j - k] == '0' && abs(a2[i + k][j] - a2[i][j + k]) == 0 &&
              abs(a1[i + k][j] - a1[i][j - k]) == 0 &&
              abs(lr[i][j + k] - lr[i][j - k]) == 0) {
            cnt++;
          }
        }
        if (i - k > 0 && j + k <= m && j - k > 0) {
          if (ar[i - k][j] == '0' && ar[i][j + k] == '0' &&
              ar[i][j - k] == '0' && abs(a1[i - k][j] - a1[i][j + k]) == 0 &&
              abs(a2[i - k][j] - a2[i][j - k]) == 0 &&
              abs(lr[i][j + k] - lr[i][j - k]) == 0) {
            cnt++;
          }
        }
        if (i - k > 0 && i + k <= n && j - k > 0) {
          if (ar[i - k][j] == '0' && ar[i + k][j] == '0' &&
              ar[i][j - k] == '0' && abs(a1[i + k][j] - a1[i][j - k]) == 0 &&
              abs(a2[i - k][j] - a2[i][j - k]) == 0 &&
              abs(ud[i - k][j] - ud[i + k][j]) == 0) {
            cnt++;
          }
        }
        if (i - k > 0 && i + k <= n && j + k <= m) {
          if (ar[i - k][j] == '0' && ar[i + k][j] == '0' &&
              ar[i][j + k] == '0' && abs(a2[i + k][j] - a2[i][j + k]) == 0 &&
              abs(a1[i - k][j] - a1[i][j + k]) == 0 &&
              abs(ud[i - k][j] - ud[i + k][j]) == 0) {
            cnt++;
          }
        }
        k++;
      }
    }
  }
  printf("%d\n", cnt);
  return 0;
}
