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:
#include<bits/stdc++.h>
#define pb push_back
using namespace std;

// int ans=0;

// bool isValid(vector<string> v, vector<vector<bool>> vis, int i, int j, int h, int w)
// {
//     return i>=0 && i<h && j>=0 && j<w && vis[i][j] == false;
// }

// void solve(vector<string> v, int h, int w, vector<vector<bool>> vis, int i, int j, int sum)
// {
//     if(!isValid(v,vis,i,j,h,w))
//         return;
//     if(i==h-1 && j==w-1) {
//         ans = max(ans,sum);
//         return;
//     }
//     vis[i][j] = true;
//     if(i< h-1 && v[i+1][j] == '.')
//         solve(v,h,w,vis,i+1,j,sum);
//     else if(i< h-1 && v[i+1][j] == '*')
//         solve(v,h,w,vis,i+1,j,sum+1);

//     if(j<w-1 && v[i][j+1] == '.')
//         solve(v,h,w,vis,i,j+1,sum);
//     else if(j<w-1 && v[i][j+1] == '*')
//         solve(v,h,w,vis,i,j+1,sum+1);
//     vis[i][j] = false;
//     return;
// }



// int main()
// {
//     int h,w;
//     string str;
//     cin>>h>>w;
//     vector<string> v;
//     for(int i=0;i<h;i++) {
//         cin>>str;
//         v.pb(str);
//     }

//     // for(int i=0;i<h;i++) {
//     //     cout<<v[i]<<"\n";
//     // }

//     //vector<int> temp(w);
//     //vector<vector<int>> dp;
//     int dp[h][w];
//     for(int i=0;i<h;i++) {
//         for(int j=0;j<w;j++)
//             dp[i][j]=0;
//     }
//     // for(int i=0;i<h;i++) {
//     //     for(int j=0;j<w;j++)
//     //         cout<<dp[i][j];
//     //     cout<<"\n";
//     // }
//     // for(int i=0;i<h;i++)
//     //     dp.pb(temp);

//     if(v[0][0] == '*')
//         dp[0][0]=1;
//     for(int i=1;i<w;i++) {
//         if(v[0][i] == '*')
//             dp[0][i] = dp[0][i-1] + 1;
//         else
//             dp[0][i] = dp[0][i-1];
//     }

//     for(int i=1;i<h;i++) {
//         if(v[i][0] == '*')
//             dp[i][0] = dp[i-1][0] + 1;
//         else
//             dp[i][0] = dp[i-1][0];
//     }

//     for(int i=0;i<h;i++) {
//         for(int j=0;j<w;j++)
//             cout<<dp[i][j]<<" ";
//         cout<<"\n";
//     }

//     for(int i=1;i<h;i++) {
//         for(int j=1;j<w;j++) {
//             dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
//             if(v[i][j] == '*')
//                 dp[i][j]++;
//         }
//     }
//     cout<<dp[h-1][w-1];

//     // vector<vector<bool>> vis;
//     // vector<bool> temp(w);
//     // for(int i=0;i<h;i++) {
//     //     vis.pb(temp);
//     // }
//     // for(int i=0;i<h;i++) {
//     //     cin>>str;
//     //     v.pb(str);
//     // }
//     // // for(int i=0;i<h;i++) {
//     // //     cout<<v[i]<<"\n";
//     // // }
//     // int tempSum=0;
//     // if(v[0][0] == '*')
//     //     tempSum=1;
//     // solve(v,h,w,vis,0,0,tempSum);
//     // cout<<ans;
// }


void solve(vector<string> v, int i, int j, int h, int w, int sum)
{
    if(i==h-1 && j==w-1) {
        cout<<sum;
        return;
    }

    if(j<w-1 && v[i][j+1] == '*')
        solve(v,i,j+1,h,w,sum+1);
    else if(i<h-1 && v[i+1][j] == '*')
        solve(v,i+1,j,h,w,sum+1);
    else if(j<w-1)
        solve(v,i,j+1,h,w,sum);
    else
        solve(v,i+1,j,h,w,sum);
    return;
}


int main()
{
    int h,w;
    string str;
    cin>>h>>w;
    vector<string> v;
    for(int i=0;i<h;i++) {
        cin>>str;
        v.pb(str);
    }
    int tempSum = 0;
    if(v[0][0] == '*')
        tempSum = 1;
    solve(v,0,0,h,w,tempSum);
}