#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#define x first
#define y second
using namespace std;
typedef pair<int,int>PII;
int dir[8][2]={2,1,-2,1,-2,-1,2,-1,1,2,-1,2,-1,-2,1,-2};
const int N = 10;
int dist[N][N];
char s1[5],s2[5];
int bfs(PII start,PII end)
{
queue<PII>q;
memset(dist,-1,sizeof dist);
dist[start.x][start.y]=0;
q.push(start);
while(q.size())
{
auto t=q.front();
q.pop();
for(int i=0;i<8;i++)
{
int x=t.x+dir[i][0];
int y=t.y+dir[i][1];
if(x<1||x>8||y<1||y>8) continue;
if(dist[x][y]!=-1) continue;
dist[x][y]=dist[t.x][t.y]+1;
if(x==end.x && y==end.y) return dist[x][y];
q.push({x,y});
}
}
return -1;
}
int main(void)
{
while(scanf("%s%s",s1,s2)!=EOF)
{
PII start,end;
start.x=s1[0]-'a'+1;
start.y=s1[1]-'0';
end.x=s2[0]-'a'+1;
end.y=s2[1]-'0';
if(start==end) printf("To get from %s to %s takes 0 knight moves.\n",s1,s2);
else printf("To get from %s to %s takes %d knight moves.\n",s1,s2,bfs(start,end));
}
return 0;
}