//Problem G: igor's solution
#include <stdio.h>
#include <string.h>

char maze[128][128];
long long t[128][128];

int main()
{
    int m, n;
    while( scanf( " %d %d", &m, &n ) == 2 )
    {
        // read maze
        for( int i = 0; i < m; i++ )
        {
            maze[i][0] = maze[i][n + 1] = '#';
            for( int j = 1; j <= n; j++ ) scanf( " %c", &maze[i][j] );
        }
        
        // dp
        memset( t, 0, sizeof( t ) );
        for( int j = 1; j <= n; j++ ) t[m - 1][j] = ( maze[m - 1][j] == '#' ? 0 : 1 );
        for( int i = m - 2; i >= 0; i-- )
            for( int j = 1; j <= n; j++ )
                t[i][j] = ( maze[i][j] == '#' ? 0 :
                    t[i + 1][j - 1] + t[i + 1][j] + t[i + 1][j + 1] );

        // count answers
        long long ans = 0;
        for( int j = 1; j <= n; j++ ) ans += t[0][j];

        // report
        printf( "%Ld\n", ans );
    }
    return 0;
}

