#include <iostream>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#define N 10
using namespace std;
int x1,y1,x2,y2;
int sum;
int dx[8]={1,2,2,1,-1,-2,-2,-1};
int dy[8]={2,1,-1,-2,-2,-1,1,2};
queue<int>xx;
queue<int>yy;
bool map[N][N];
int l[N][N];
bool inmap(int x,int y)
{
return (x<=8&&y<=8&&x>0&&y>0);//判断是否越界
}
void bfs(int x,int y)
{
for(int k=0;k<8;k++)
{
if(inmap(x+dx[k],y+dy[k])&&!map[x+dx[k]][y+dy[k]])
{
map[x+dx[k]][y+dy[k]]=true;
l[x+dx[k]][y+dy[k]]=l[x][y]+1;
xx.push(x+dx[k]);
yy.push(y+dy[k]);
if(x+dx[k]==x2&&y+dy[k]==y2)
{
sum=l[x+dx[k]][y+dy[k]];
return ;
}
}
}
if(!xx.empty())
{
xx.pop();
yy.pop();
}
if(!xx.empty())
{
bfs(xx.front(),yy.front());
}
}
int main()
{
char s[10];
while(gets(s))//特殊输入
{
sum=0;
x1 = (int)s[0] - 96;
y1 = (int)s[1] - 48;
x2 = (int)s[3] - 96;
y2 = (int)s[4] - 48;
while(!xx.empty())
{
xx.pop();
yy.pop();
}
memset(map,false,sizeof(map));
memset(l,0,sizeof(l));
xx.push(x1);
yy.push(y1);
map[x1][y1]=true;
l[x1][y1]=0;
bfs(x1,y1);
cout <<"To get from "<<s[0]<<y1<<" to "<<s[3]<<y2<<" takes "<<sum<<" knight moves."<< endl;
}
return 0;
}