#include <bits/stdc++.h>
using namespace std;
template <typename S, typename T>
ostream& operator<<(ostream& out, pair<S, T> const& p) {
  out << '(' << p.first << ", " << p.second << ')';
  return out;
}
template <typename T>
ostream& operator<<(ostream& out, vector<T> const& v) {
  long long l = v.size();
  for (long long i = 0; i < l - 1; i++) out << v[i] << ' ';
  if (l > 0) out << v[l - 1];
  return out;
}
template <typename T>
void trace(const char* name, T&& arg1) {
  cout << name << " : " << arg1 << "\n";
}
template <typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | ";
  trace(comma + 1, args...);
}
const long long N = 405;
long long n, m;
vector<string> arr;
vector<vector<long long> > cumu;
bool check(long long a, long long b) {
  return (a >= 0 and a < n and b >= 0 and b < m);
}
bool one(long long a, long long b, long long c) {
  long long temp = cumu[a][c];
  if (b != 0) {
    temp -= cumu[a][b - 1];
  }
  return (temp > 0);
}
void printmat() {
  for (long long i = 0; i < n; i++) {
    cout << arr[i] << "\n";
  }
}
void rotate() {
  string temp = "";
  for (long long i = 0; i < n; i++) {
    temp += "*";
  }
  vector<string> b(m, temp);
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      b[j][n - 1 - i] = arr[i][j];
    }
  }
  arr = b;
  n = arr.size();
  m = arr[0].size();
  cumu.clear();
  cumu.resize(n, vector<long long>(m));
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      cumu[i][j] = (arr[i][j] == '1');
      if (j != 0) {
        cumu[i][j] += cumu[i][j - 1];
      }
    }
  }
}
long long get() {
  n = arr.size();
  m = arr[0].size();
  long long cnt = 0;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      long long ans = 0;
      if (arr[i][j] == '1') continue;
      for (long long k = 1; k < n; k++) {
        if (check(i + k, j + k)) {
          if (arr[i + k][j] == '1' or arr[i + k][j + k] == '1') {
            break;
          }
          if (one(i + k, j, j + k)) {
            continue;
          }
          ans++;
        } else {
          break;
        }
      }
      cnt += ans;
    }
  }
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      if (arr[i][j] == '1') continue;
      long long ans = 0;
      for (long long k = 1; k < max(n, m); k++) {
        if (check(i + k, j + k) and check(i + k, j - k)) {
          if (arr[i + k][j - k] == '1' or arr[i + k][j + k] == '1') {
            break;
          }
          if (one(i + k, j - k, j + k)) {
            continue;
          }
          ans++;
        } else {
          break;
        }
      }
      cnt += ans;
    }
  }
  return cnt;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> m;
  for (long long i = 0; i < n; i++) {
    string temp;
    cin >> temp;
    arr.push_back(temp);
  }
  cumu.clear();
  cumu.resize(n, vector<long long>(m));
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      cumu[i][j] = (arr[i][j] == '1');
      if (j != 0) {
        cumu[i][j] += cumu[i][j - 1];
      }
    }
  }
  long long ans = 0;
  for (long long i = 0; i < 4; i++) {
    long long temp = get();
    ans += temp;
    rotate();
  }
  cout << ans << "\n";
  return 0;
}
