Problem: A mouse encountered a nice big cake and decided to take a walk across it, eating the berries on top of the cake on its way. The cake is rectangular, neatly divided into squares; some of the squares have a berry in them, and some don't.

The mouse is in a bit of a hurry, though, so once she enters the cake from its northwest corner (the top left cell in the input data), she will only go east (right) or south (down), until she reaches the southeast corner (the bottom right cell). She will eat every berry in the squares she passes through, but not in the other squares.

The mouse tries to choose her path so as to maximize the number of berries consumed. However, her haste and hunger might be clouding her judgement, leading her to suboptimal decisions...

Input

The first line of input contains two integers H and W (1 ≤ H, W ≤ 5), separated by a space, — the height and the width of the cake.

The next H lines contain a string of W characters each, representing the squares of the cake in that row: '.' represents an empty square, and '*' represents a square with a berry.

Output

Output the number of berries the mouse will eat following her strategy.

Examples

Input


4 3
*..
.*.
..*
...


Output


3


Input


4 4
.*..
*...
...*
..*.


Output


2


Input


3 4
..**
*...
....


Output


1


Input


5 5
..*..
.....
**...
**...
**...


Output


1

Solution (in JAVA):

Solution:
import java.util.Scanner;

public class E {
    public static int[][] movements = {{0, 1}, {1,0}};

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int w, h;
        h = sc.nextInt();
        w = sc.nextInt();
        sc.nextLine();
        String[][] board = new String[h][w];
        for (int i = 0; i < h; i++) {
            char[] aux = sc.nextLine().toCharArray();
            for (int j = 0; j < w; j++) {
                board[i][j] = String.valueOf(aux[j]);
            }
        }
        //boolean[][] visited = new boolean[h][w];
        //System.out.println(BT(board, 0, 0, h, w, 0, Integer.MIN_VALUE, visited));
        int counterInit = (board[0][0].equals("*")) ? 1 : 0;
        System.out.println(BT(board, 0, 0, h, w, counterInit, Integer.MIN_VALUE));
    }

//    private static int BT(String[][] board, int posX, int posY, int finX, int finY, int counter, int maxCounter, boolean[][] visited){
    private static int BT(String[][] board, int posX, int posY, int finX, int finY, int counter, int maxCounter){
        if ((posX==finX-1 && posY == finY-1) || counter < maxCounter){
            maxCounter = Math.max(counter, maxCounter);
            return maxCounter;
        }else{
            for (int i = 0; i < movements.length; i++) {
                int x1 = posX + movements[i][0];
                int y1 = posY + movements[i][1];

                int x2 = posX + movements[i][1];
                int y2 = posY + movements[i][0];
                if (isFeasible(x1, y1, finX, finY) && isFeasible(x2, y2, finX, finY)){
                    if (isBetter(x1, y1, x2, y2, board)){
                        maxCounter = BT(board, x1, y1, finX, finY, counter+1, maxCounter);
                    }else if (isBetter(x2, y2, x1, y1, board)){
                        maxCounter = BT(board, x2, y2, finX, finY, counter+1, maxCounter);
                    }else{
                        if(board[x1][y1].equals("*")){
                            maxCounter = BT(board, x1, y1, finX, finY, counter+1, maxCounter);
                        }else{
                            maxCounter = BT(board, x1, y1, finX, finY, counter, maxCounter);
                        }
                    }
                }else if (isFeasible(x1, y1, finX, finY)){
                    if(board[x1][y1].equals("*")){
                        maxCounter = BT(board, x1, y1, finX, finY, counter+1, maxCounter);
                    }else{
                        maxCounter = BT(board, x1, y1, finX, finY, counter, maxCounter);
                    }
                }else if (isFeasible(x2, y2, finX, finY)){
                    if(board[x2][y2].equals("*")){
                        maxCounter = BT(board, x2, y2, finX, finY, counter+1, maxCounter);
                    }else{
                        maxCounter = BT(board, x2, y2, finX, finY, counter, maxCounter);
                    }
                }
            }
        }
        return maxCounter;
    }

    private static boolean isBetter(int x1, int y1, int x2, int y2, String[][] board) {
        return (board[x1][y1].equals("*") && !board[x2][y2].equals("*"));
    }

    private static boolean isFeasible(int x, int y, int rows, int cols){
        return (0 <= x && x < rows) && (0 <= y && y < cols);
    }
}