#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct pos
{
int count, x, y;
friend bool operator < ( pos a, pos b)
{
return a. count> b. count;
}
} ;
int dir[ 4 ] [ 2 ] = { 0 , 1 , 0 , - 1 , 1 , 0 , - 1 , 0 } ;
char arr[ 205 ] [ 205 ] ;
int vis[ 205 ] [ 205 ] , n, m;
void bfs ( int x, int y)
{
priority_queue< pos> qu;
pos cur, nex;
cur. x= x;
cur. y= y;
cur. count= 0 ;
qu. push ( cur) ;
while ( ! qu. empty ( ) )
{
cur= qu. top ( ) ;
qu. pop ( ) ;
if ( arr[ cur. x] [ cur. y] == 'r' )
{
cout<< cur. count<< endl;
return ;
}
for ( int i= 0 ; i< 4 ; i++ )
{
nex. x= cur. x+ dir[ i] [ 0 ] ;
nex. y= cur. y+ dir[ i] [ 1 ] ;
if ( ! vis[ nex. x] [ nex. y] && arr[ nex. x] [ nex. y] != '#' && nex. x>= 0 && nex. x< n&& nex. y>= 0 && nex. y< m)
{
vis[ nex. x] [ nex. y] = 1 ;
if ( arr[ nex. x] [ nex. y] == 'x' )
nex. count= cur. count+ 2 ;
else
nex. count= cur. count+ 1 ;
qu. push ( nex) ;
}
}
}
cout<< "Poor ANGEL has to stay in the prison all his life." << endl;
return ;
}
int main ( )
{
int stx, sty;
while ( scanf ( "%d%d" , & n, & m) == 2 )
{
for ( int i= 0 ; i< n; i++ )
for ( int j= 0 ; j< m; j++ )
{
cin>> arr[ i] [ j] ;
if ( arr[ i] [ j] == 'a' )
{
stx= i;
sty= j;
}
}
memset ( vis, 0 , sizeof ( vis) ) ;
vis[ stx] [ sty] = 1 ;
bfs ( stx, sty) ;
}
return 0 ;
}