#include <bits/stdc++.h>
inline void in(int &MAGNUS) { scanf("%d", &MAGNUS); }
inline void out(int MAGNUS) { printf("%d\n", MAGNUS); }
inline void in(int &MAGNUS, int &CLAR) { scanf("%d%d", &MAGNUS, &CLAR); }
inline void out(int MAGNUS, int CLAR) { printf("%d %d\n", MAGNUS, CLAR); }
inline void inl(long long &LIV) { scanf("%lld", &LIV); }
inline void inl(long long &LIV, long long &MART) {
  scanf("%lld%lld", &LIV, &MART);
}
inline void outl(long long LIV) { printf("%lld\n", LIV); }
inline void outl(long long LIV, long long MART) {
  printf("%lld %lld\n", LIV, MART);
}
using namespace std;
int dx[] = {-1, 0, 1, 0, -1, -1, 1, 1};
int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};
int R, C, x[405][405], sum[8][405][405];
bool inside(int r, int c) { return 1 <= r && r <= R && 1 <= c && c <= C; }
int rsum(int dir, int r1, int c1, int r2, int c2) {
  return abs(sum[dir][r2][c2] - sum[dir][r1 - dx[dir]][c1 - dy[dir]]);
}
int main() {
  in(R, C);
  for (int i = 1; i <= R; i++) {
    for (int j = 1; j <= C; j++) {
      char ch;
      cin >> ch;
      x[i][j] = ch - '0';
    }
  }
  for (int dir = 0; dir <= 7; dir++) {
    for (int i = 1; i <= R; i++) {
      for (int j = 1; j <= C; j++) {
        if (inside(i - dx[dir], j - dy[dir])) continue;
        int r = i, c = j;
        while (inside(r, c)) {
          if (r == i && c == j)
            sum[dir][r][c] = x[i][j];
          else
            sum[dir][r][c] = x[r][c] + sum[dir][r - dx[dir]][c - dy[dir]];
          r += dx[dir];
          c += dy[dir];
        }
      }
    }
  }
  long long ans = 0;
  for (int i = 1; i <= R; i++) {
    for (int j = 1; j <= C; j++) {
      for (int dir = 0; dir <= 3; dir++) {
        for (int k = 1; k <= min(R, C); k++) {
          int r1 = i + dx[dir] * k, c1 = j + dy[dir] * k;
          int r2 = i + dx[(dir + 1) % 4] * k, c2 = j + dy[(dir + 1) % 4] * k;
          if (!inside(r1, c1) || !inside(r2, c2)) continue;
          int s1 = rsum(dir, i, j, r1, c1),
              s2 = rsum((dir + 1) % 4, i, j, r2, c2),
              s3 = rsum(dir + 4, r2, c2, r1, c1);
          ans += (s1 == 0 && s2 == 0 && s3 == 0);
        }
        for (int k = 1; k <= min(R, C); k++) {
          int r1 = i + dx[dir] * k, c1 = j + dy[dir] * k;
          int r2 = i + dx[(dir + 1) % 4] * k, c2 = j + dy[(dir + 1) % 4] * k;
          int r3 = i + dx[(dir + 2) % 4] * k, c3 = j + dy[(dir + 2) % 4] * k;
          if (!inside(r1, c1) || !inside(r2, c2) || !inside(r3, c3)) continue;
          int s1 = rsum(dir, i, j, r1, c1), s2 = rsum(dir + 4, r2, c2, r1, c1);
          int s3 = rsum((dir + 2) % 4, i, j, r3, c3),
              s4 = rsum((dir + 1) % 4 + 4, r3, c3, r2, c2);
          ans += (s1 == 0 && s2 == 0 && s3 == 0 && s4 == 0);
        }
      }
    }
  }
  outl(ans);
  return 0;
}
