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 CPP):

Solution:
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include <algorithm>
#include <array>
#include <cassert>
//#include <chrono>
#include <cmath>
//#include <cstring>
//#include <functional>
//#include <iomanip>
#include <iostream>
#include <map>
//#include <numeric>
//#include <queue>
//#include <random>
#include <set>
#include <vector>
using namespace std;
#define FAST  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp> 
//using namespace __gnu_pbds; 
#define int long long 
#define ll int
#define all(a) a.begin(),a.end()	
#define rev(a) a.rbegin(),a.rend()	
//typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; //less_equal for multiset
#define ar array
#define pb push_back
#define fi(a,b) for(int i=a;i<(b);i++)
#define fj(a,b) for(int j=a;j<(b);j++)
#define fk(a,b) for(int k=a;k<(b);k++)
const double pi=acosl(-1);

int n,m;
vector<string> a;
int ans=0;
// void rec(int x,int y,int count)
// {
// 	if(x<n&&y<m)
// 	{
// 		if(a[x][y]=='*') count++;
// 	}
// 	if(x==n-1&&y==m-1)
// 	{
// 		ans=max(ans,count);
// 		return ;
// 	}
// 	if(x>=n||y>=m) return ;
// 	rec(x+1,y,count);
// 	rec(x,y+1,count);
// }

int dist=1e15;
pair<int,int> t;
pair<int,int> p;
void dfs(int x,int y)
{
	// cout<<x<<' '<<y<<'\n';
	// cout<<dist<<'\n';
	if(a[x][y]=='*'&&(x!=p.first||y!=p.second))
	{
		if(x-p.first+y-p.second==dist)
		{
			if(y>t.second)
			{
				t={x,y};
			}
		}
		if(x-p.first+y-p.second<dist)
		{
			t={x,y};
			dist=x-p.first+y-p.second;
		}
	}
	if(x+1<n)
	{
		dfs(x+1,y);
	}
	if(y+1<m)
	{
		dfs(x,y+1);
	}
}


void solve()
{
	ans=0;
	cin>>n>>m;
	a=vector<string> (n);
	fi(0,n)
	{
		cin>>a[i];
	}
	// rec(0,0,0);
	int x=0,y=0;
	if(a[0][0]=='*') ans++;
	while(1)
	{
		if(y==m-1)
		{
			fj(x+1,n)
			{
				if(a[j][m-1]=='*') ans++;
			}
			break;
		}
		if(x==n-1)
		{
			fj(y+1,m)
			{
				if(a[n-1][j]=='*') ans++;
			}
			break;
		}
		if(x==n-1&&y==m-1)
		{
			assert(false);
		}
		//find next nearest
		// cout<<x<<' '<<y<<'\n';
		t={n-1,m-1};
		p={x,y};
		dist=1e15;
		dfs(x,y);
		if(a[t.first][t.second]=='*'){
			ans++;
		}
		x=t.first;
		y=t.second;
		// cout<<x<<' '<<y<<'\n';
		// cout<<dist<<'\n';
	}
	cout<<ans<<'\n';

	
	
}

signed main()
{
	FAST;
	int tt=1;
	// cin>>tt;   
	while(tt--)
	{
		solve();
	}
}










//int dx[] = {+1,-1,+0,+0,-1,-1,+1,+1}; // Eight Directions
//int dy[] = {+0,+0,+1,-1,+1,-1,-1,+1}; // Eight Directions
//int dx[]= {-2,-2,-1,1,-1,1,2,2}; // Knight moves
//int dy[]= {1,-1,-2,-2,2,2,-1,1}; // Knight moves
// For (a^b)%mod, where b is large, replace b by b%(mod-1).
// a+b = (a|b)+(a&b)
// a+b = 2*(a&b)+(a^b)