#include<stdio.h>
#include <queue>
using namespace std;
struct node { int x,y,cnt; }
int dir[8][2]={1,2,1,-2,-1,2,-1,-2,2,1,2,-1,-2,1,-2,-1};
bool check(int x, int y)
{
if(x >= 0 && x <=7 && y >= 0 && y <=7)
return true;
return false;
}
int bfs(int sx,int sy,int ex,int ey)
{ bool visited[20][20]={false};
queue<node> q;
node cur={sx,sy,0};
visited[sx][sy]=true;
q.push(cur);
while(!q.empty())
{
cur=q.front();
q.pop();
if(cur.x==ex&&cur.y==ey)
{
return cur.cnt;
}
for(int i=0;i<7;i++)
{
int x=cur.x+dir[i][0];
int y=cur.y+dir[i][1];
if(check(x,y) && visited[x][y]==false)
{
visited[x][y]=true;
node tmp = {x, y, cur.cnt + 1};
q.push(tmp);
}
}
}
}
int main()
{
char sx, sy, ex, ey;
while(scanf("%c%c %c%c" ,&sx,&sy,&ex,&ey)!=EOF)
{ getchar();
sx -= 'a', sy = sy - '0' - 1;
ex -= 'a', ey = ey - '0' - 1;//保持一致。
printf("To get from %c%d to %c%d takes %d knight moves.\n",
sx + 'a', sy + 1, ex + 'a', ey + 1, BFS(sx, sy, ex,ey));
}
return 0;
}