//* Problem  : D
//* Contest  : UzhNU Local
//* Origin   : Ulm-1996
//* Type     : Solution
//* Date     : 2008.02.04
//* Author   : alt
//* Language : C++
//* Compiler : Microsoft Visual C++ 6.0
//* Algoritm : Straightforward

#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#include <queue>

struct point{
	int x, y;
};

int n, a[100];

char s[100];

int d[32][32];

const int dx[] = { -2,  -2,  -1,  -1,  1,   1,  2,  2};
const int dy[] = { -1,   1,  -2,   2, -2,   2, -1,  1};

int solve()
{
	int x0 = s[0] - 'a', y0 = s[1] - '1', x1 = s[3] - 'a', y1 = s[4] - '1', x, y, dd;
	memset(d, 0, sizeof(d));
	std::queue <point> q; point p; p.x = x0; p.y = y0; d[x0][y0] = 1; q.push(p);
	while (!d[x1][y1])
	{
		p = q.front(); q.pop(); x0 = p.x; y0 = p.y; dd = d[x0][y0];
		for (int i = 0; i < 8; i++)
		{
			x = x0 + dx[i]; y = y0 + dy[i];
			if (x < 0 || x >= 8 || y < 0 || y >= 8) continue;
			if (!d[x][y])
			{
				d[x][y] = dd + 1; p.x = x; p.y = y; q.push(p);
			}
		}
	}
	return d[x1][y1] - 1;
}

int main()
{
	int nt = 0;
	while (1)
	{
		s[0] = 0; gets(s); if (!s[0]) break;
		printf("To get from %c%c to %c%c takes %d knight moves.\n", s[0], s[1], s[3], s[4], solve());
	}
	return 0;
}