#include <bits/stdc++.h>
using namespace std;
queue<int> X,Y,SN;
bool Marked[8][8], Found;
int Ex,Ey,Sx,Sy;
void StartProcess()
{
string s;
getline(cin,s);
Sx=int(s[0])-int('A'); Sy=int(s[1])-int('1');
Ex=int(s[3])-int('A');
Ey=int(s[4])-int('1');
for (int i=0; i<8; i++)
for (int j=0; j<8; j++) Marked[i][j]=false;
X.push(Sx); Y.push(Sy); SN.push(0);
}
void PutAll(int x, int y, int sn, bool &Found)
{
int steps[8][2] = {{1,-2},{1,2},{-1,-2},{-1,2},{2,-1},{2,1},{-2,-1},{-2,1}};
Found = false;
for (int i=0; (i<8) and (not Found); i++)
{
int Cx=x+steps[i][0];
int Cy=y+steps[i][1];
Found = (Ex==Cx) && (Ey==Cy);
if ((Cx>=0) && (Cx<8) &&
(Cy>=0) && (Cy<8) &&
(not Marked[Cx][Cy]))
{X.push(Cx); Y.push(Cy); SN.push(sn); Marked[Cx][Cy]=true;};
}
}
int main()
{
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
StartProcess();
Found=(Sx==Ex) && (Sy==Ey);
while (not Found)
{
int x = X.front(); X.pop();
int y = Y.front(); Y.pop();
int sn=SN.front(); SN.pop();
sn++;
PutAll(x,y,sn,Found);
}
cout << SN.back(); }