/**
换了个分类开始做题。。
一道简单的搜索题。。一开始本来想把所有情况都打表出来的。。感觉数据量太小没必要了。。。
*/
#if 1
#include <iostream>
#include <string>
#include <queue>
#include <string.h>
#include <cstdio>
using namespace std;
int a[ 10][10]={0};
int b[10][10]={0};
struct step{
int x;
int y;
int count;
step(int c,int d,int e){x=c;y=d;count= e;}
//step(struct step s){x= s.x;y=s.y;cout=s.count;}
};
queue <struct step> Q1,Q2;
int dx[]={1,2,2,1,-1,-2,-2,-1};
int dy[]={-2,-1,1,2,2,1,-1,-2};
int isOK(int X,int Y)
{
if(X > 0 && X< 9 && Y >0 && Y<9) return 1;
else return 0;
}
int dfs(int x1,int y1,int x2 ,int y2)
{
memset(a,0,sizeof(a));
memset(b,0,sizeof(b));
while(!Q1.empty())Q1.pop();
Q1.push(step(x1,y1,0));
b[x1][y1] = 1;
while(!Q1.empty())
{
struct step nowStep = Q1.front();
if(nowStep.x == x2 &&nowStep.y == y2)return nowStep.count;
Q1.pop();
for(int i = 0; i < 8 ; i++)
{
int X= dx[i] + nowStep.x;
int Y= dy[i] + nowStep.y;
if(!isOK(X,Y) || b[X][Y] > 0 )continue;
b[X][Y] = 1;
a[X][Y] = nowStep.count+1;
Q1.push(step(X,Y,nowStep.count+1));
}
}
}
int main()
{
string str1,str2;
while(cin>>str1>>str2)
{
int S = dfs(str1[0] - 'a' + 1 ,str1[1] - '0' ,str2[0] - 'a' + 1 ,str2[1]-'0');
printf("To get from %s to %s takes %d knight moves.\n",str1.c_str(),str2.c_str(),S);
}
return 0;
}
#endif