#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int arr[n + 1][m + 1];
  for (int x = 0; x < n; x++) {
    string s;
    cin >> s;
    for (int y = 0; y < m; y++) {
      if (s[y] == '0') {
        arr[x + 1][y + 1] = 1;
      } else {
        arr[x + 1][y + 1] = 0;
      }
    }
  }
  int ver[n + 2][m + 2], hor[n + 2][m + 2], diaadd[n + 2][m + 2],
      diadiff[n + 2][m + 2];
  memset(ver, 0, sizeof(ver));
  memset(hor, 0, sizeof(hor));
  memset(diaadd, 0, sizeof(diaadd));
  memset(diadiff, 0, sizeof(diadiff));
  for (int x = 1; x <= n; x++) {
    for (int y = 1; y <= m; y++) {
      ver[x][y] += ver[x - 1][y];
      hor[x][y] += hor[x][y - 1];
      diadiff[x][y] += diadiff[x - 1][y - 1];
      if (arr[x][y]) {
        ver[x][y] += 1;
        hor[x][y] += 1;
        diadiff[x][y] += 1;
      }
    }
  }
  for (int x = 1; x <= n; x++) {
    for (int y = m; y >= 1; y--) {
      diaadd[x][y] += diaadd[x - 1][y + 1];
      if (arr[x][y]) {
        diaadd[x][y] += 1;
      }
    }
  }
  for (int x = 1; x <= n; x++) {
    for (int y = 1; y <= m; y++) {
    }
  }
  long int cnt = 0;
  for (int x = 1; x <= n; x++) {
    for (int y = 1; y <= m; y++) {
      if (!arr[x][y]) {
        continue;
      }
      int cnt1 = 0;
      for (int ab = 1; ab <= n; ab++) {
        if (x - ab > 0 && y + ab <= m && arr[x - ab][y] == 1 &&
            arr[x][y + ab] == 1) {
          int a = ver[x][y] - ver[x - ab][y], b = hor[x][y + ab] - hor[x][y],
              c = diadiff[x][y + ab] - diadiff[x - ab][y];
          if (a == ab && b == ab && c == ab) {
            cnt1++;
          }
        }
        if (x - ab > 0 && y - ab > 0 && arr[x - ab][y] == 1 &&
            arr[x][y - ab] == 1) {
          int a = ver[x][y] - ver[x - ab][y], b = hor[x][y] - hor[x][y - ab],
              c = diaadd[x][y - ab] - diaadd[x - ab][y];
          if (a == ab && b == ab && c == ab) {
            cnt1++;
          }
        }
        if (x + ab <= n && y - ab > 0 && arr[x + ab][y] == 1 &&
            arr[x][y - ab] == 1) {
          int a = ver[x + ab][y] - ver[x][y], b = hor[x][y] - hor[x][y - ab],
              c = diadiff[x + ab][y] - diadiff[x][y - ab];
          if (a == ab && b == ab && c == ab) {
            cnt1++;
          }
        }
        if (x + ab <= n && y + ab <= m && arr[x + ab][y] == 1 &&
            arr[x][y + ab] == 1) {
          int a = ver[x + ab][y] - ver[x][y], b = hor[x][y + ab] - hor[x][y],
              c = diaadd[x + ab][y] - diaadd[x][y + ab];
          if (a == ab && b == ab && c == ab) {
            cnt1++;
          }
        }
        if (x - ab > 0 && y + ab <= m && y - ab > 0 &&
            arr[x - ab][y + ab] == 1 && arr[x - ab][y - ab] == 1) {
          int a = diaadd[x][y] - diaadd[x - ab][y + ab],
              b = diadiff[x][y] - diadiff[x - ab][y - ab],
              c = hor[x - ab][y + ab] - hor[x - ab][y - ab];
          if (a == ab && b == ab && c == 2 * ab) {
            cnt1++;
          }
        }
        if (x - ab > 0 && x + ab <= n && y - ab > 0 &&
            arr[x + ab][y - ab] == 1 && arr[x - ab][y - ab] == 1) {
          int a = diadiff[x][y] - diadiff[x - ab][y - ab],
              b = diaadd[x + ab][y - ab] - diaadd[x][y],
              c = ver[x + ab][y - ab] - ver[x - ab][y - ab];
          if (a == ab && b == ab && c == 2 * ab) {
            cnt1++;
          }
        }
        if (x + ab <= n && y + ab <= m && y - ab > 0 &&
            arr[x + ab][y + ab] == 1 && arr[x + ab][y - ab] == 1) {
          int a = diadiff[x + ab][y + ab] - diadiff[x][y],
              b = diaadd[x + ab][y - ab] - diaadd[x][y],
              c = hor[x + ab][y + ab] - hor[x + ab][y - ab];
          if (a == ab && b == ab && c == 2 * ab) {
            cnt1++;
          }
        }
        if (x - ab > 0 && x + ab <= n && y + ab <= m &&
            arr[x + ab][y + ab] == 1 && arr[x - ab][y + ab] == 1) {
          int a = diadiff[x + ab][y + ab] - diadiff[x][y],
              b = diaadd[x][y] - diaadd[x - ab][y + ab],
              c = ver[x + ab][y + ab] - ver[x - ab][y + ab];
          if (a == ab && b == ab && c == 2 * ab) {
            cnt1++;
          }
        }
      }
      cnt += cnt1;
    }
  }
  cout << cnt << endl;
}
