#include <iostream>
#include<string>
using namespace std;
const int N = 10;
int dir[8][2]={{-2,1},{-1,2},{1,2},{2,1},{2,-1},{1,-2},{-1,-2},{-2,-1}};
int sx,sy,ex,ey;
int used[N][N];
//int xy[MAXN][MAXN];
void bfs(int x,int y, int t)
{
if(x>8||x<1|| y < 1 || y > 8 || used[x][y] <= t)
return;//注意不要踏出棋盘
used[x][y] = t;
for(int i = 0; i < 8; i++)
{
int tx = x + dir[i][0];
int ty = y + dir[i][1];
bfs(tx, ty, t + 1);
}
}
int main()
{
//char d1, d2, d;
//char c1, c2;
//int a, b;
string s1, s2;
while(cin >>s1 >> s2)//a, b为行
{
//int c1, c2, a, b;
sx = s1[0] - 'a' + 1;
sy = s1[1] - '0';
ex = s2[0] - 'a' + 1;
ey = s2[1] - '0';
for(int i = 1; i <= 8; i++)
{
for(int j = 1; j <= 8; j++)
{
used[i][j] = 64;
}
}
bfs(sx, sy, 0);
//cout << c1 << " " << a << " " << c2 << " " << b;
/*if(sx == ex && sy == ey)
{
cout << "To get from " << s1 << " to " << s2 << " takes 0 knight moves." << endl;continue;
}
else
{*/
//bfs(sx, sy);
cout << "To get from "<< s1 << " to "<< s2 << " takes " << used[ex][ey] << " knight moves."<<endl;
// }
}
return 0;
}