import java.util.*;
import java.lang.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

class Ideone {

    public static class Pair<T1, T2> {
        public T1 fst;
        public T2 snd;

        public Pair(T1 t1, T2 t2) {

            this.fst = t1;
            this.snd = t2;
        }
    }

    public static void main(String[] args) 
 {
        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[][] = new int[8][8];
        Scanner s = new Scanner(System.in);
        String str;
        while (s.hasNextLine()) {
            String line = s.nextLine();
            Pattern p = Pattern.compile("^(.)(\\d) (.)(\\d)$");
            Matcher m = p.matcher(line);
            m.find();
            a = m.group(1).toCharArray()[0];
            ny = Integer.parseInt(m.group(2));
            b = m.group(3).toCharArray()[0];
            ty = Integer.parseInt(m.group(4));
            nx = a - 'a';
            ny--;
            tx = b - 'a';
            ty--;
            A[nx][ny] = 0;
            Queue<Pair<Integer, Integer>> q = new LinkedList<Pair<Integer, Integer>>();
            q.add(new Pair<Integer, Integer>(nx, ny));
            while (!q.isEmpty()) {
                Pair<Integer, Integer> c = q.peek();
                int x = c.fst, y = c.snd;
                if (x == tx && y == ty) break;
                q.remove();
                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.add(new Pair<Integer, Integer>(x + mx[i], y + my[i]));
                        A[x + mx[i]][y + my[i]] = A[x][y] + 1;
                    }
                }
            }
            System.out.printf("To get from %c%d to %c%d takes %d knight moves.\n", a, ny + 1, b, ty + 1, A[tx][ty]);
        }
    }
}