#include <iostream>
#include <fstream>
using namespace std;
ifstream f("date.in");
char a[10][10];
int n,m;

void citire()
{
    int i,j;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            cin>>a[i][j];
        }
    }
}

void afisare()
{
    int i,j;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            cout<<a[i][j]<<" ";
        }
        cout<<endl;
    }
}

void prel()
{
    int s=1,i,j;
    i=j=1;
    if(n>=m)
    {
        for(i=1;i<=n;)
        {
            if(a[i+1][j]!='&')
            {
                i++;
                s++;
            }
            else
                if(a[i][j+1]!='&')
                {
                    j++;
                    s++;
                }
                else
                    break;

        }
    }
    else
    {
        for(j=1;j<=m;)
        {
            if(a[i][j+1]!='&')
            {
                j++;
                s++;
            }
            else
                if(a[i+1][j]!='&')
                {
                    i++;
                    s++;
                }
                else
                    break;
        }
    }
    cout<<s;
}
int main()
{
    int i,j;
   cin>>n>>m;
    citire();

    afisare();
    prel();
    f.close();
    return 0;
}