#include <string>       // std::string
#include <iostream>     // std::cout
#include <sstream> 
#include <vector>

using namespace std;

int n;
int m;
vector<string> a;
int sol = 0;

void Rec(int row, int col, int path)
{
    
    if ((row == n || col == m))
    {
        // solution
        if (path > sol) sol = path;
        return;
    }
    if (a[row][col] == '&')
    {
        // solution
        if (path > sol) sol = path;
        return;
    }
    // go down
    Rec(row + 1, col, path + 1);

    // go right
    Rec(row, col + 1, path + 1);
}

int main()
{
    string tmp;
    getline(cin, tmp);
    stringstream ss(tmp);
    ss >> n; ss >> m;
    

    for(int i=0; i<n; i++)
    {
        getline(std::cin, tmp);
        a.push_back(tmp);
    }

    Rec(0,0,0);

    cout << sol;

    return 0;
}
/*
4 4
..&.
..&.
..&.
..&.
*/