def moves(x,y):
s=0
while x>4 or y>4:
if x>y>0:
x-=2
y-=1
elif y>=x>0:
x-=1
y-=2
elif x==0:
x+=1
y-=2
elif y==0:
x-=2
y+=1
s+=1
if x<y:
x,y=y,x
if (x,y)in((2,2),(4,4)):
s+=4
elif (x,y) in ((1,0),(3,0),(4,1),(4,3),(3,2)):
s+=3
elif (x,y) in ((4,0),(4,2),(3,3),(3,1),(2,0),(1,1)):
s+=2
elif (x,y)==(2,1):
s+=1
return s
corner=(['a1','b2'],['a8','b7'],['h1','g2'],['h8','g7'])
try:
point=raw_input()
while point!='':
point=point.split()
if point in corner or point[1:]+point[:1] in corner:
s=4
else:
s=moves(abs(ord(point[0][0])-ord(point[1][0])),abs(ord(point[0][1])-ord(point[1][1])))
print("To get from %s to %s takes %d knight moves."%(point[0],point[1],s))
point=raw_input()
except:
pass
/**************************************************************
Problem: 2124
User: admin
Language: Python
Result: Wrong Answer
****************************************************************/