#include<iostream>
#include<cstring>
#include<cstdio>
#include<queue>
using namespace std;
struct node
{
int x,y,step;
};
node s,e;
bool vis[10][10];
int d[8][2]={{1,2},{-1,2},{2,1},{-2,1},{1,-2},{-1,-2},{2,-1},{-2,-1}};
queue<node>q;
int bfs(node s,node e)
{
node p;
while(!q.empty()) q.pop();
int dx,dy;
while(1)
{
if(s.x==e.x&&s.y==e.y) return s.step;
for(int i=0;i<8;i++)
{
dx=s.x+d[i][0];
dy=s.y+d[i][1];
if(dx<0||dx>=8||dy<0||dy>=8||vis[dx][dy]) continue;
p.x=dx,p.y=dy,p.step=s.step+1;vis[dx][dy]=true;
q.push(p);
}
s=q.front();q.pop();
}
}
int main()
{
char a[3],b[3];
while (scanf("%s%s",a,b)!=EOF) {
s.x=a[0]-'a';s.y=a[1]-'1';
e.x=b[0]-'a';e.y=b[1]-'1';
s.step=0;
memset(vis,false,sizeof(vis));
printf("To get from %s to %s takes %d knight moves.\n",a,b,bfs(s,e));
}
return 0;
}