#include <iostream>
#include <string>
#include <queue>
#include <cstring>
using namespace std;
struct point
{
int x;
int y;
point ( const int x= - 1 , const int y= - 1 ) : x ( x) , y ( y) { }
} ;
point operator + ( const point& A, const point& B)
{
return point ( A. x + B. x, A. y + B. y) ;
}
bool operator == ( const point& A, const point& B)
{
return A. x == B. x && A. y == B. y;
}
point start, final;
point dir[ 8 ] = { { 1 , - 2 } , { 2 , - 1 } , { 2 , 1 } , { 1 , 2 } ,
{ - 1 , 2 } , { - 2 , 1 } , { - 2 , - 1 } , { - 1 , - 2 } } ;
int vis[ 8 ] [ 8 ] ;
bool isvalid ( point start, point direct)
{
if ( start. x + direct. x > 7 || start. x + direct. x < 0
|| start. y + direct. y> 7 || start. y + direct. y < 0 )
return false ;
return true ;
}
void getpoint ( string s, string e)
{
start. x = s[ 0 ] - 'a' , start. y = s[ 1 ] - '1' ;
final. x = e[ 0 ] - 'a' , final. y = e[ 1 ] - '1' ;
}
int solve ( )
{
memset ( vis, 0 , sizeof ( vis) ) ;
queue< point> q;
q. push ( start) ;
point cur;
while ( ! q. empty ( ) )
{
cur = q. front ( ) ; q. pop ( ) ;
if ( cur == final)
{
return vis[ final. x] [ final. y] ;
}
for ( int i = 0 ; i < 8 ; ++ i)
{
if ( isvalid ( cur, dir[ i] ) )
{
point jump = cur + dir[ i] ;
if ( vis[ jump. x] [ jump. y] == 0 )
{
vis[ jump. x] [ jump. y] = vis[ cur. x] [ cur. y] + 1 ;
q. push ( jump) ;
}
}
}
}
}
int main ( )
{
string s, e;
while ( cin >> s >> e)
{
getpoint ( s, e) ;
cout << "To get from " << s << " to " << e << " takes " << solve ( ) << " knight moves.\n" ;
}
}