#include<cstdio>
#include<queue>
using namespace std;
char a, b;
int nx, ny, tx, ty;
int mx[] = { -1, -1, 1, 1, -2, -2, 2, 2 };
int my[] = { 2, -2, 2, -2, 1, -1, 1, -1 };
int A[8][8];
int main() {
while(scanf("%c%d %c%d\n", &a, &ny, &b, &ty) == 4) {
nx = a - 'a';
ny--;
tx = b - 'a';
ty--;
A[nx][ny] = 0;
queue< pair<int, int> > q;
q.push(make_pair(nx, ny));
while(!q.empty()) {
pair<int, int> c = q.front();
int x = c.first, y = c.second;
if(x == tx && y == ty) break;
q.pop();
for(int i = 0; i < 8; i++) {
if(x + mx[i] >= 0 && x + mx[i] < 8 && y + my[i] >= 0 && y + my[i] < 8) {
q.push(make_pair(x + mx[i], y + my[i]));
A[x + mx[i]][y + my[i]] = A[x][y] + 1;
}
}
}
printf("To get from %c%d to %c%d takes %d knight moves.\n", a, ny + 1, b, ty + 1, A[tx][ty]);
}
}
I2luY2x1ZGU8Y3N0ZGlvPgojaW5jbHVkZTxxdWV1ZT4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKIApjaGFyIGEsIGI7CmludCBueCwgbnksIHR4LCB0eTsKaW50IG14W10gPSB7IC0xLCAtMSwgMSwgMSwgLTIsIC0yLCAyLCAyIH07CmludCBteVtdID0geyAyLCAtMiwgMiwgLTIsIDEsIC0xLCAxLCAtMSB9OwppbnQgQVs4XVs4XTsKIAppbnQgbWFpbigpIHsKICAgIHdoaWxlKHNjYW5mKCIlYyVkICVjJWRcbiIsICZhLCAmbnksICZiLCAmdHkpID09IDQpIHsKICAgICAgICBueCA9IGEgLSAnYSc7CiAgICAgICAgbnktLTsKICAgICAgICB0eCA9IGIgLSAnYSc7CiAgICAgICAgdHktLTsKICAgICAgICBBW254XVtueV0gPSAwOwogICAgICAgIHF1ZXVlPCBwYWlyPGludCwgaW50PiA+IHE7CiAgICAgICAgcS5wdXNoKG1ha2VfcGFpcihueCwgbnkpKTsKICAgICAgICB3aGlsZSghcS5lbXB0eSgpKSB7CiAgICAgICAgICAgIHBhaXI8aW50LCBpbnQ+IGMgPSBxLmZyb250KCk7CiAgICAgICAgICAgIGludCB4ID0gYy5maXJzdCwgeSA9IGMuc2Vjb25kOwogICAgICAgICAgICBpZih4ID09IHR4ICYmIHkgPT0gdHkpIGJyZWFrOwogICAgICAgICAgICBxLnBvcCgpOwogICAgICAgICAgICBmb3IoaW50IGkgPSAwOyBpIDwgODsgaSsrKSB7CiAgICAgICAgICAgICAgICBpZih4ICsgbXhbaV0gPj0gMCAmJiB4ICsgbXhbaV0gPCA4ICYmIHkgKyBteVtpXSA+PSAwICYmIHkgKyBteVtpXSA8IDgpIHsKICAgICAgICAgICAgICAgICAgICBxLnB1c2gobWFrZV9wYWlyKHggKyBteFtpXSwgeSArIG15W2ldKSk7CiAgICAgICAgICAgICAgICAgICAgQVt4ICsgbXhbaV1dW3kgKyBteVtpXV0gPSAgQVt4XVt5XSArIDE7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgcHJpbnRmKCJUbyBnZXQgZnJvbSAlYyVkIHRvICVjJWQgdGFrZXMgJWQga25pZ2h0IG1vdmVzLlxuIiwgYSwgbnkgKyAxLCBiLCB0eSArIDEsIEFbdHhdW3R5XSk7CiAgICB9Cn0=