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.io.*;
import java.nio.CharBuffer;
import java.util.LinkedList;
import java.util.NoSuchElementException;
import java.util.Queue;

public class P1505E_2 {

    public static void main(String[] args) {
        SimpleScanner scanner = new SimpleScanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);

        int h = scanner.nextInt();
        int w = scanner.nextInt();
        char[][] grid = new char[h][];
        for (int i = 0; i < h; ++i)
            grid[i] = scanner.next().toCharArray();

        int r = 0;
        int c = 0;
        int result = 0;
        while (r != h - 1 || c != w - 1) {
            int[] next = findNext(grid, r, c, h, w);
            r = next[0];
            c = next[1];
            if (grid[r][c] == '*') {
                grid[r][c] = '.';
                ++result;
            }
        }
        writer.println(result);

        writer.close();
    }

    private static int[] findNext(char[][] grid, int r, int c, int h, int w) {
        Queue<int[]> queue = new LinkedList<>();
        queue.offer(new int[]{r, c});
        int[] p = null;
        while (!queue.isEmpty()) {
            p = queue.poll();
            if (grid[p[0]][p[1]] == '*') {
                break;
            }
            if (p[1] < w - 1) {
                queue.offer(new int[]{p[0], p[1] + 1});
            }
            if (p[0] < h - 1) {
                queue.offer(new int[]{p[0] + 1, p[1]});
            }
        }
        return p;
    }

    private static class SimpleScanner {

        private static final int BUFFER_SIZE = 10240;

        private Readable in;
        private CharBuffer buffer;
        private boolean eof;

        private SimpleScanner(InputStream in) {
            this.in = new BufferedReader(new InputStreamReader(in));
            buffer = CharBuffer.allocate(BUFFER_SIZE);
            buffer.limit(0);
            eof = false;
        }


        private char read() {
            if (!buffer.hasRemaining()) {
                buffer.clear();
                int n;
                try {
                    n = in.read(buffer);
                } catch (IOException e) {
                    n = -1;
                }
                if (n <= 0) {
                    eof = true;
                    return '\0';
                }
                buffer.flip();
            }
            return buffer.get();
        }

        private void checkEof() {
            if (eof)
                throw new NoSuchElementException();
        }

        private char nextChar() {
            checkEof();
            char b = read();
            checkEof();
            return b;
        }

        private String next() {
            char b;
            do {
                b = read();
                checkEof();
            } while (Character.isWhitespace(b));
            StringBuilder sb = new StringBuilder();
            do {
                sb.append(b);
                b = read();
            } while (!eof && !Character.isWhitespace(b));
            return sb.toString();
        }

        private int nextInt() {
            return Integer.parseInt(next());
        }

        private long nextLong() {
            return Long.parseLong(next());
        }

        private double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}