// Arup Guha
// 10/11/2023
// Solution to COP 3502 Section 4 Exam 1 Part B Question 1

#include <stdio.h>
#include <stdlib.h>

#define MAX 10

int numways(char** grid, int n, int r, int c);

int main() {

    // Read in grid size.
    int n;
    scanf("%d", &n);

    // Allocate memory.
    char** grid = calloc(n, sizeof(char*));

    // Read in grid.
    for (int i=0; i<n; i++) {
        grid[i] = calloc(n+1, sizeof(char));
        scanf("%s", grid[i]);
    }

    // Run it!
    printf("%d\n", numways(grid, n, 0, 0));

    // Clean up.
    for (int i=0; i<n; i++)
        free(grid[i]);
    free(grid);
    return 0;

}

// Returns the number of ways in the grid to walk from (r, c) to (n-1, n-1), only moving
// down and right and only going to squares with the '.' character. Guaranteed that (r,c)
// and (n-1,n-1) both have '.'.
int numways(char** grid, int n, int r, int c) {

    // We're there.
    if (r == n-1 && c == n-1) return 1;

    // Add ways we can go by going down, if possible.
    int res = 0;
    if (r < n-1 && grid[r+1][c] == '.')
        res += numways(grid, n, r+1, c);

    // Same for moving right...
    if (c < n-1 && grid[r][c+1] == '.')
        res += numways(grid, n, r, c+1);

    // Ta da!
    return res;
}
