#include <iostream>
#include <cmath>
using namespace std;
long long h, w;
long long onSumToY[1042][1042];
char c[512][512];
long long ans = 0;


bool ok ( long long x, long long y ) {
    if ( x < 0 || x >= w || y < 0 || y >= h ) { return 0; }
    return 1;
}
long long dist ( long long x1, long long y1, long long x2, long long y2 ) {
    return abs( x1 - x2 ) + abs ( y1 - y2 );
}
void solve () {
    for ( long long i = 0 ; i < 1024 ; i ++ ) {
        for ( long long sum = 0 ; sum < 1024;  sum ++ ) { onSumToY[i][sum] = 0; }
    }

    for ( long long i = 0 ; i < h ; i ++ ) {
        for ( long long j = 0 ; j < w ; j ++ ) {
            if ( c[i][j] == '#' ) { onSumToY[i][i+j] ++; }
        }
    }

    for ( long long i = 1 ; i < 1024 ; i ++ ) {
        for ( long long sum = 0 ; sum < 1024; sum ++ ) {
            onSumToY[i][sum] += onSumToY[i-1][sum];
        }
    }

    for ( long long y = 0 ; y < h ; y ++ ) {
        for ( long long x = 0 ; x < w ; x ++ ) {
            for ( long long k = 1 ; k <= min( w, h ) ; k ++ ){

                if ( c[y][x] == '.' ) { continue; }

                long long x1 = x+k, y1 = y-k;
                if ( !ok( x1, y1 ) || c[y1][x1] == '.' ) { continue; }


                long long crr1 = 0;
                if ( x+y+k+k ) {
                    crr1 += onSumToY[y+k][ x+y+k+k ];
                    if ( y-1 >= 0 ) { crr1 -= onSumToY[y-1][x+y+k+k]; }

                    //cout << crr1 << " <-- \n";

                }


                long long crr2 = 0;
                if ( y-k >= 0 && x+y -k-k >= 0 ) {
                    crr2 += onSumToY[y-k][ x+y-k-k ];
                    if ( y-2*k-1 >= 0 ) { crr2 -= onSumToY[y-2*k-1][x+y-k-k]; }

                    //cout << "summing " << onSumToY[y-k][ x+y-k-k] << " " << y-k << " " << x+y-k-k << " <-- \n";
                }

                //cout << y << " " << x << " " << k << " +: " << crr1 << " + " << crr2 << "\n";

                ans += crr1;
                ans += crr2;

                continue;


            }
        }
    }
}
char c2[512][512];

int main () {

    cin >> h >> w;
    for ( long long i = 0 ; i < h ; i ++ ) {
        cin >> c[i];
    }
    solve();

    for ( long long y = 0 ; y < h ; y ++ ) {
        for ( long long x = 0 ; x < w ; x ++ ) {
            c2[h-1-y][x] = c[y][x];
        }
    }

    //swap( h, w );
    for ( long long y = 0 ; y < h ; y ++ ) {
        for ( long long x = 0 ; x < w ; x ++ ) {
            c[y][x] = c2[y][x];
        }
    }
/*
    for ( long long y = 0 ; y < h ; y ++ ) {
        for ( long long x = 0 ; x < w ; x ++ ) {
            cout << c[y][x];
        }
        cout << "\n";
    }
*/

    solve();

    for ( long long y = 0 ; y < h ; y ++ ) {
        for ( long long x = 0 ; x < w ; x ++ ) {
            for ( long long k = 1 ; k <= min( w, h ) ; k ++ ){

                if ( c[y][x] == '.' ) { continue; }

                long long xLU = x-k, xLD = x-k, xRU = x+k, xRD = x+k;
                long long yLU = y-k, yLD = y+k, yRU = y-k, yRD = y+k;

                if ( ok( xLU, yLU ) && ok( xLD, yLD ) && c[yLD][xLD] == '#' && c[yLU][xLU] == '#' ) { ans --;  }
                if ( ok( xLU, yLU ) && ok( xRU, yRU ) && c[yRU][xRU] == '#' && c[yLU][xLU] == '#' ) { ans --;  }

                if ( ok( xRD, yRD ) && ok( xLD, yLD ) && c[yLD][xLD] == '#' && c[yRD][xRD] == '#' ) { ans --;  }
                if ( ok( xRD, yRD ) && ok( xRU, yRU ) && c[yRU][xRU] == '#' && c[yRD][xRD] == '#' ) { ans --; }

            }
        }
    }


    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 8832