#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]);
    }
}