Two chess pieces, a rook and a knight, stand on a standard chessboard 8 × 8 in size. The positions in which they are situated are known. It is guaranteed that none of them beats the other one.Your task is to find the number of ways to place another knight on the board so that none of the three pieces on the board beat another one. A new piece can only be placed on an empty square.

The first input line contains the description of the rook's position on the board. This description is a line which is 2 in length. Its first symbol is a lower-case Latin letter from a to h, and its second symbol is a number from 1 to 8. The second line contains the description of the knight's position in a similar way. It is guaranteed that their positions do not coincide.

Print a single number which is the required number of ways.

type mas = array[0..9] of longint;
matr =  array[0..9] of mas;

z=record
  x,y:longint;
end;

var
  i,n,ans,j: longint;
  ma:matr;
  c1,c2,c3,c4: char;
  kon,lad,p,po:z;

  procedure rea(a,b:char);
    var
      x,y:longint;
    begin
      x := ord(a)-ord('a') + 1;
      y := ord(b) -ord('0');
      ma[x,y] := 1;
    end;

  function good(a:z): boolean;
    begin
      good := (a.x<=8) and (a.x >=1) and (a.y <= 8) and (a.y >=1);
    end;

    function good2(a:z): boolean;
      var
        p:z;
        f:boolean;
      begin

        f:=true;
          p.x:=a.x - 2;
          p.y := a.y + 1;
          if (good(p)) and (((p.x = kon.x) and (p.y=kon.y)) or ((p.x = lad.x) and (p.y=lad.y))) then f := false;

          p.x:=a.x - 1;
         p.y := a.y + 2;
          if (good(p)) and (((p.x = kon.x) and (p.y=kon.y)) or ((p.x = lad.x) and (p.y=lad.y))) then f := false;

         p.x:=a.x + 1;
          p.y := a.y + 2;
         if (good(p)) and (((p.x = kon.x) and (p.y=kon.y)) or ((p.x = lad.x) and (p.y=lad.y))) then f := false;

         p.x:=a.x + 2;
         p.y := a.y + 1;
          if (good(p)) and (((p.x = kon.x) and (p.y=kon.y)) or ((p.x = lad.x) and (p.y=lad.y))) then f := false;

         p.x:=a.x - 2;
         p.y := a.y - 1;
          if (good(p)) and (((p.x = kon.x) and (p.y=kon.y)) or ((p.x = lad.x) and (p.y=lad.y))) then f := false;

          p.x:=a.x -1;
          p.y := a.y -2;
          if (good(p)) and (((p.x = kon.x) and (p.y=kon.y)) or ((p.x = lad.x) and (p.y=lad.y))) then f := false;

         p.x:=a.x + 1;
         p.y := a.y - 2;
          if (good(p)) and (((p.x = kon.x) and (p.y=kon.y)) or ((p.x = lad.x) and (p.y=lad.y))) then f := false;

          p.x:=a.x + 2;
          p.y := a.y - 1;
           if (good(p)) and (((p.x = kon.x) and (p.y=kon.y)) or ((p.x = lad.x) and (p.y=lad.y))) then f := false;

        good2 := f;
      end;

begin
 { assign(input, 'input.txt');
  assign(output, 'output.txt');
  reset(input);
  rewrite(output);  }
  readln(c1,c2);
  read(c3,c4);

  lad.x := ord(c1)-ord('a') + 1;
  lad.y := ord(c2) -ord('0');

  kon.x := ord(c3)-ord('a') + 1;
  kon.y := ord(c4) -ord('0');
  rea(c1,c2);
  rea(c3,c4);

  p.x:=kon.x - 2;
  p.y := kon.y + 1;
  if good(p) then ma[p.x,p.y] := 1;

  p.x:=kon.x - 1;
  p.y := kon.y + 2;
  if good(p) then ma[p.x,p.y] := 1;

  p.x:=kon.x + 1;
  p.y := kon.y + 2;
  if good(p) then ma[p.x,p.y] := 1;

  p.x:=kon.x + 2;
  p.y := kon.y + 1;
  if good(p) then ma[p.x,p.y] := 1;

  p.x:=kon.x - 2;
  p.y := kon.y - 1;
  if good(p) then ma[p.x,p.y] := 1;

  p.x:=kon.x -1;
  p.y := kon.y -2;
  if good(p) then ma[p.x,p.y] := 1;

  p.x:=kon.x + 1;
  p.y := kon.y - 2;
  if good(p) then ma[p.x,p.y] := 1;

  p.x:=kon.x + 2;
  p.y := kon.y - 1;
  if good(p) then ma[p.x,p.y] := 1;

  for i := 1 to 8 do
    ma[i,lad.y] := 1;

  for j := 1 to 8 do
    ma[lad.x,j] := 1;

  ans := 0;

  for i := 1 to 8 do
    for j := 1 to 8 do
      begin
        po.x := i;
        po.y := j;
        if ma[po.x,po.y] = 0 then
        if good2(po) then inc(ans);
      end;

  write(ans);

 { close(input);
  close(output); }
end.

program storm;
var dosk:array[-20..20,-20..20] of char;
    kol,nom1,nom2:longint;

procedure lad(b:char; nom:longint);
var i,j:longint;
begin
 dosk[9-(ord(b)-96),nom]:='*';
 for i:=1 to 8 do
  if dosk[i,nom]<>'*' then dosk[i,nom]:='#';
 for i:=1 to 8 do
  if dosk[(9-(ord(b)-96)),i]<>'*' then dosk[(9-(ord(b)-96)),i]:='#';
end;

procedure kon(b:char; nom:longint);
var nom1,nom2:longint;
begin
 nom1:=9-(ord(b)-96); nom2:=nom;
 dosk[nom1,nom2]:='*';
 dosk[nom1-1,nom2-2]:='#'; dosk[nom1-2,nom2-1]:='#';
 dosk[nom1+1,nom2-2]:='#'; dosk[nom1+2,nom2-1]:='#';
 dosk[nom1+1,nom2+2]:='#'; dosk[nom1+2,nom2+1]:='#';
 dosk[nom1-1,nom2+2]:='#'; dosk[nom1-2,nom2+1]:='#';
end;

procedure outputdata;
begin
 writeln(kol);
end;

procedure inputdata;
var chiclo1,chiclo2,code:longint;
    c1,c2:char;
    s1,s2:string;
begin
 readln(s1);
 readln(s2);
 c1:=s1[1]; c2:=s2[1];
 val(s1[2],chiclo1,code); val(s2[2],chiclo2,code);
 lad(c1,chiclo1);
 kon(c2,chiclo2);
end;

begin
 inputdata; kol:=0;
 for nom1:=1 to 8 do
  for nom2:=1 to 8 do
  if (dosk[nom1,nom2]<>'*') and (dosk[nom1,nom2]<>'#') and (dosk[nom1-1,nom2-2
  ]<>'*') and
   (dosk[nom1-2,nom2-1]<>'*') and (dosk[nom1+1,nom2-2]<>'*') and (dosk[nom1+2,nom2-1]<>'*') and
    (dosk[nom1+1,nom2+2]<>'*') and (dosk[nom1+2,nom2+1]<>'*') and (dosk[nom1-1,nom2+2]<>'*')
     and (dosk[nom1-2,nom2+1]<>'*') then inc(kol);
 outputdata;
end.

{$apptype console}

const d : array [1..8, 1..2] of integer = ((1,2),(1,-2),(-1,2),(-1,-2),(2,1),(2,-1),(-2,1),(-2,-1));

var lx, ly, kx, ky: integer;
    m : array [1..8, 1..8] of boolean;
    t : string;

procedure conv( const s : string; var x, y : integer );
begin
   x := ord(s[2]) - ord('1') + 1;
   y := ord(s[1]) - ord('a') + 1;
end;

procedure Mark( x, y : integer );
begin
  if( x>=1) and(y>=1) and (x<=8) and(y<=8 ) then m[y][x] := false;
end;

function Check( x0, y0 : integer ) : boolean;
var i, x, y : integer;
begin
  result := true;
  for i := 1 to 8 do begin
     x := x0 + d[i][1];
     y := y0 + d[i][2];
     if ((x=lx)and(y=ly)) then begin result := false; break; end;
  end;
end;

var x,y, i, s : integer;
begin
  readln( t );
  Conv( t, lx, ly );
  readln( t );
  Conv( t, kx, ky );
{}
  for x := 1 to 8 do
     for y := 1 to 8 do
        if (x = lx ) or (y=ly ) then m[y][x]:=false else m[y][x] := true;

  m[ky][kx] := false;
  for i := 1 to 8 do Mark( kx + d[i][1], ky + d[i][2] );
{}
  s := 0;
  for x := 1 to 8 do
     for y := 1 to 8 do
        if m[y][x] and Check( x, y ) then inc( s );
{}
  write( s );
end.

program task;
var ls,ks,ln,kn:char;
    a:array[-1..10,-1..10]of byte;
    xl,xk,yl,yk,i,j,count:integer;
begin
//  assign(input,'input.txt');
//  assign(output,'output.txt');
  read(ls);readln(ln);
  read(ks);read(kn);
  xl:=ord(ls)-ord('a')+1; xk:=ord(ks)-ord('a')+1;
  yl:=ord(ln)-ord('0'); yk:=ord(kn)-ord('0');
  for i:=1 to 8 do begin
    a[yl,i]:=1; a[i,xl]:=1;
  end;
  a[yl,xl]:=3;
  if (yk+2<9)and(xk-1>0)then
    a[yk+2,xk-1]:=1;
  if (yk+2<9)and(xk+1<9)then
    a[yk+2,xk+1]:=1;
  if (yk+1<9)and(xk+2<9)then
    a[yk+1,xk+2]:=1;
  if (yk-1>0)and(xk+2<9)then
    a[yk-1,xk+2]:=1;
  if (yk-2>0)and(xk-1>0)then
    a[yk-2,xk-1]:=1;
  if (yk-2<9)and(xk+1<9)then
    a[yk-2,xk+1]:=1;
  if (yk+1<9)and(xk-2>0)then
    a[yk+1,xk-2]:=1;
  if (yk-1>0)and(xk-2>0)then
    a[yk-1,xk-2]:=1;
  a[yk,xk]:=3;
  count:=0;
  for i:=1 to 8 do
    for j:=1 to 8 do
      if (a[i,j]=0)and
         (a[i+2,j-1]<>3)and(a[i+2,j+1]<>3)and
         (a[i-2,j-1]<>3)and(a[i-2,j+1]<>3)and
         (a[i+1,j-2]<>3)and(a[i+1,j+2]<>3)and
         (a[i-1,j-2]<>3)and(a[i-1,j+2]<>3)then
           inc(count);
  writeln(count);
end.

Var a,b:char;
    q,w,i,j,k,l,ans:longint;
    x:array[1..8] of char;
    c:array[-100..100,-100..100] of boolean;
    Begin
  readln(a,i);
  readln(b,j);
  for q:=1 to 8 do
   for w:=1 to 8 do
    c[q,w]:=true;
  x[1]:='a';
  x[2]:='b';
  x[3]:='c';
  x[4]:='d';
  x[5]:='e';
  x[6]:='f';
  x[7]:='g';
  x[8]:='h';
  for q:=1 to 8 do
   begin
    if a=x[q] then k:=q;
    if b=x[q] then l:=q;
   end;
  c[k,i]:=false;
  c[k+2,i+1]:=false;
  c[k+2,i-1]:=false;
  c[k-2,i+1]:=false;
  c[k-2,i-1]:=false;
  c[k+1,i+2]:=false;
  c[k+1,i-2]:=false;
  c[k-1,i+2]:=false;
  c[k-1,i-2]:=false;
  c[l+2,j+1]:=false;
  c[l+2,j-1]:=false;
  c[l-2,j+1]:=false;
  c[l-2,j-1]:=false;
  c[l+1,j+2]:=false;
  c[l+1,j-2]:=false;
  c[l-1,j-2]:=false;
  c[l-1,j+2]:=false;
  c[l,j]:=false;
  for q:=1 to 8 do
   c[k,q]:=false;
  for q:=1 to 8 do
   c[q,i]:=false;
  for q:=1 to 8 do
   for w:=1 to 8 do
    begin
     if c[q,w] then inc(ans);
    end;
  writeln(ans);
 End.

program Project5;

{$APPTYPE CONSOLE}

uses
  SysUtils;

Var
   A, B, C, N, X1, X2, Y1, Y2, E, F : integer;
  S1, S2 : string;
  I : boolean;
begin
  Readln(S1);
  Readln(S2);
  if S1[1] = 'a' then X1 := 1;
  if S1[1] = 'b' then X1 := 2;
  if S1[1] = 'c' then X1 := 3;
  if S1[1] = 'd' then X1 := 4;
  if S1[1] = 'e' then X1 := 5;
  if S1[1] = 'f' then X1 := 6;
  if S1[1] = 'g' then X1 := 7;
  if S1[1] = 'h' then X1 := 8;
  if S2[1] = 'a' then X2 := 1;
  if S2[1] = 'b' then X2 := 2;
  if S2[1] = 'c' then X2 := 3;
  if S2[1] = 'd' then X2 := 4;
  if S2[1] = 'e' then X2 := 5;
  if S2[1] = 'f' then X2 := 6;
  if S2[1] = 'g' then X2 := 7;
  if S2[1] = 'h' then X2 := 8;
  Y1 := strtoint(S1[2]);
  Y2 := strtoint(S2[2]);
  C := 0;
  for A := 1 to 8 do
  begin
    for B := 1 to 8 do
    begin
      I := true;
      if (A = X1) or (B = Y1) then I := false;
      if (A = X2) and (B = Y2) then I := false;
      E := abs(X2 - A);
      F := abs(Y2 - B);

      if ((E = 2) and (f = 1)) or ((E = 1) and  (F = 2)) then I := false;

      E := abs(X1 - A);
      F := abs(Y1 - B);
      if ((E = 2) and (f = 1)) or ((E = 1) and  (F = 2)) then I := false;

      if I = true then C := C + 1;

    end;
  end;

  writeln(C);
  readln(c);

end.

var
  a:array[1..8,1..8] of integer;
  i,j,x1,y1,x2,y2,k,f:integer;
  s1,s2:string;
begin
  readln(s1);
  readln(s2);
  x1:=ord(s1[1])-96; y1:=ord(s1[2])-48; //�����
  x2:=ord(s2[1])-96; y2:=ord(s2[2])-48; //����
  k:=0;
  for i:=1 to 8 do
  for j:=1 to 8 do
    begin
    //  if (i<>x1)and(j<>y1)and(i<>x2)and(j<>y2) then
        begin
          f:=0;//�� ����
          if ((abs(i-x1)=1)and(abs(j-y1)=2))or((abs(i-x1)=2)and(abs(j-y1)=1))then f:=1;//���� �����
          if ((abs(i-x2)=1)and(abs(j-y2)=2))or((abs(i-x2)=2)and(abs(j-y2)=1))then f:=1;//���� ����
          if (x1=i)or(y1=j) then f:=1;//����� ���� ����
          if f=0 then inc(k);
        end;
    end;
  writeln(k-1);
end.

program Project1;
{$APPTYPE CONSOLE}
{$R+}
uses
SysUtils;
var
k,x1,y1,j,i,x,y:longint;
a:array[-100..100,-100..100]of boolean;
b:array[-1..800,-1..800]of boolean;
s:string;
begin
//reset(input,'input.txt');rewrite(output,'output.txt');

readln(s);
x1:=strtoint(s[2]);
y1:=ord(s[1])-96;

read(s);
x:=strtoint(s[2]);
y:=ord(s[1])-96;
a[x,y]:=true;
a[x1,y1]:=true;

for i:=1 to 8 do
for j:=1 to 8 do
begin
if a[i-1,j-2] then b[i,j]:=true;
if a[i-2,j-1] then b[i,j]:=true;
if a[i+1,j+2] then b[i,j]:=true;
if a[i+2,j+1] then b[i,j]:=true;
if a[i+1,j-2] then b[i,j]:=true;
if a[i+2,j-1] then b[i,j]:=true;
if a[i-1,j+2] then b[i,j]:=true;
if a[i-2,j+1] then b[i,j]:=true;
end;

for i:=1 to 8 do
for j:=1 to 8 do
if b[i,j] then a[i,j]:=true;

for i:=1 to 8 do
a[x1,i]:=true;
for i:=1 to 8 do
a[i,y1]:=true;

k:=0;
for i:=1 to 8 do
for j:=1 to 8 do
if not a[i,j] then inc(k);

write(k);
end.

program aa;

{$APPTYPE CONSOLE}

uses
  SysUtils;

const
  h = 8;
  v = 8;
  dx: array [1..h] of integer = (-2, -1, 1, 2, 1, 2, -2, -1);
  dy: array [1..v] of integer = (1, 2, -2, -1, 2, 1, -1, -2);
  inf = -1;
  maxN = 100;
type
  Tpoint = record
  x, y: integer;
end;
var
  str1, str2: string;
  s, tmp, e: Tpoint;
  i, j, k: integer;
  d: array[-2..maxN + 2,  -2..maxN + 2] of integer;
Label masha;
begin
  k := 0;
  readln(str1);
  readln(str2);

  fillchar(d, sizeof(d), 0);
  s.x := ord(str1[1]) - 96;
  s.y := ord(str1[2]) - 48;
  e.x := ord(str2[1]) - 96;
  e.y := ord(str2[2]) - 48;
  for i := 1 to h do
    d[s.x , i] := 1;
  for i := 1 to h do
    d[i, s.y] := 1;
  for i := 1 to 8 do begin
      tmp.x := e.x + dx[i];
      tmp.y := e.y + dy[i];
      d[tmp.x, tmp.y] := 1;
  end;
   for i := 1 to 8 do begin
      tmp.x := s.x + dx[i];
      tmp.y := s.y + dy[i];
      d[tmp.x, tmp.y] := 1;
  end;
  d[e.x, e.y] := 1;
  for i := -2 to 0 do
    for j := -2 to h do
      d[i , j] := 0;
  for i := -2 to h do
    for j := -2 to 0 do
      d[i , j] := 0;

   for i := 1 to h do
    for j := 1 to h do
     if d[i, j] = 0 then inc(k);
   writeln(k);
  end.

program Project22222;

{$APPTYPE CONSOLE}

uses
  SysUtils;

const
  dx: array [1..8] of Longint = (2, 2, -2, -2, 1, 1, -1, -1);
  dy: array [1..8] of Longint = (1, -1, 1, -1, 2, -2, 2, -2);
var
  a: array [1..8, 1..8] of Byte;
  ch1, ch2: Char;
  r, c, j, k, i, rx, ry, kx, ky: Longint;

function correct(x, y: Integer): Boolean;
begin
  correct := (x >= 1) and (x <= 8) and (y >= 1) and (y <= 8);
end;

begin
{
  Reset(Input,'in.txt');
  Rewrite(Output,'out.txt');
}
  Read(ch1, ch2);
  case ch1 of
    'a': rx:= 1;
    'b': rx:= 2;
    'c': rx:= 3;
    'd': rx:= 4;
    'e': rx:= 5;
    'f': rx:= 6;
    'g': rx:= 7;
    'h': rx:= 8;
  end;
  ry:= StrToInt(ch2);

  Readln;
  c:= 0;
  Read(ch1, ch2);
  case ch1 of
    'a': kx:= 1;
    'b': kx:= 2;
    'c': kx:= 3;
    'd': kx:= 4;
    'e': kx:= 5;
    'f': kx:= 6;
    'g': kx:= 7;
    'h': kx:= 8;
  end;
  ky:= StrToInt(ch2);

  for i := 1 to 8 do begin
    a[rx, i] := 1;
    a[i, ry] := 1;
  end;

  for i := 1 to 8 do begin
    if correct(kx + dx[i], ky + dy[i]) then begin
      a[kx + dx[i], ky + dy[i]] := 1;
    end;
  end;

  a[rx, ry] := 2;
  a[kx, ky] := 2;

  for i := 1 to 8 do begin
    for j := 1 to 8 do begin
      if a[i, j] > 0 then begin
        inc(c);
        continue;
      end;
      for k := 1 to 8 do begin
        if not correct(i + dx[k], j + dy[k]) then begin
          continue;
        end;
        if (a[i + dx[k], j + dy[k]] = 2) then begin
          r := 1;
          break;
        end;
      end;
      if r = 1 then begin
        inc(c);
        r := 0;
      end;
    end;
  end;

  Writeln(64 - c);

end.

program solution;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  s1, s2 : string;
  ans, x1, y1, x2, y2, i, j : integer;
  used : array[0..9, 0..9] of boolean;

begin
  //reset(input, 'input.txt');
  //rewrite(output, 'output.txt');
  readln(s1);
  readln(s2);
  x1 := 9 - ord(s1[2]) + ord('0');
  y1 := ord(s1[1]) - ord('a') + 1;
  x2 := 9 - ord(s2[2]) + ord('0');
  y2 := ord(s2[1]) - ord('a') + 1;
  used[x1, y1] := true;
  used[x2, y2] := true;
  ans := 0;
  for i := 1 to 8 do
    for j := 1 to 8 do
      if not used[i, j] then begin
        if (i = x1) or (j = y1) or ((abs(i - x2) > 0) and (abs(j - y2) > 0) and (abs(i - x2) + abs(j - y2) = 3)) or ((abs(i - x1) > 0) and (abs(j - y1) > 0) and (abs(i - x1) + abs(j - y1) = 3)) then
          continue;
        inc(ans);
      end;
  write(ans);
end.

type kieu = record
                r,c:integer;
            end;
const fi = '';
      fo = '';
      col:array['a'..'h'] of integer = (1,2,3,4,5,6,7,8);
      dr:array[1..8] of integer = (-2,-1,1,2,2,1,-1,-2);
      dc:array[1..8] of integer = (1,2,2,1,-1,-2,-2,-1);
var res:longint;
    posr,posk:kieu;
    check:array[1..8,1..8] of boolean;
procedure nhap;
var f:Text;
    rt,kt:string;
begin
    assign(f,fi); reset(f);
    readln(f,rt);
    readln(f,kt);
    posr.c:=col[rt[1]]; posr.r:=ord(rt[2])-48;
    posk.c:=col[kt[1]]; posk.r:=ord(kt[2])-48;
    close(f);
end;
procedure solve;
var i,r,c:longint;
begin
    res:=48;
    check[posr.r,posr.c]:=true;
    check[posk.r,posk.c]:=true;
    for i:=1 to 8 do check[posr.r,i]:=true;
    for i:=1 to 8 do check[i,posr.c]:=true;
    for i:=1 to 8 do
    begin
        r:=posr.r+dr[i]; c:=posr.c+dc[i];
        if (r<=8) and (r>=1) and (c<=8) and (c>=1) and (not check[r,c]) then
        begin
            check[r,c]:=true; dec(res);
        end;
    end;
    for i:=1 to 8 do
    begin
        r:=posk.r+dr[i]; c:=posk.c+dc[i];
        if (r<=8) and (r>=1) and (c<=8) and (c>=1) and (not check[r,c]) then
        begin
            check[r,c]:=true; dec(res);
        end;
    end;
end;
procedure xuat;
var f:text;
begin
    assign(f,fo); rewrite(f);
    writeln(f,res);
    close(F);
end;
begin
    nhap;
    solve;
    xuat;
end.

var x1,x2,y1,y2,i,j,k:longint;
    q:string;
    a:array[-100..100,-100..100] of longint;
    p:integer;
function tt:boolean;
var q1,q2,q3:boolean;
    i,j:longint;
 begin
  q1:=true;
  q2:=true;
  q3:=true;
  for i:=1 to 8 do
   begin
    if a[i,y1]=3 then q1:=false;
    if a[x1,i]=3 then q1:=false;
   end;
  for i:=1 to 8 do
   for j:=1 to 8 do
    begin
     if a[i,j]=3 then begin
                       if a[i-2,j-1] in [1,2] then q3:=false;
                       if a[i-2,j+1] in [1,2] then q3:=false;
                       if a[i+2,j-1] in [1,2] then q3:=false;
                       if a[i+2,j+1] in [1,2] then q3:=false;
                       if a[i-1,j-2] in [1,2] then q3:=false;
                       if a[i-1,j+2] in [1,2] then q3:=false;
                       if a[i+1,j-2] in [1,2] then q3:=false;
                       if a[i+1,j+2] in [1,2] then q3:=false;
                      end;
    end;
  if q1 and q3 then tt:=true
               else tt:=false;
 end;
 begin
  readln(q);
  x1:=ord(q[1])-96;
  val(q[2],y1,p);
  readln(q);
  x2:=ord(q[1])-96;
  val(q[2],y2,p);
  k:=0;
  fillchar(a,sizeof(a),0);
  a[x1,y1]:=1;
  a[x2,y2]:=2;
  for i:=1 to 8 do
   for j:=1 to 8 do
    if a[i,j]=0 then begin
                      a[i,j]:=3;
                      if tt then k:=k+1;
                      a[i,j]:=0;
                     end;
  writeln(k);
 end.

program b1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  s:string;
  x,y,x1,y1,i,j,r:longint;

begin
  readln(s);
  x:=ord(s[1])-ord('a')+1;
  y:=ord(s[2])-ord('0');
  readln(s);
  x1:=ord(s[1])-ord('a')+1;
  y1:=ord(s[2])-ord('0');
  r:=0;
  for i:=1 to 8 do
    for j:=1 to 8 do
       if (i<>x)and(j<>y)and((x1<>i)or(y1<>j)) then
         begin
           if (((abs(i-x1)=2)and(abs(j-y1)=1))or
              ((abs(i-x1)=1)and(abs(j-y1)=2)))or
              (((abs(i-x)=2)and(abs(j-y)=1))or
              ((abs(i-x)=1)and(abs(j-y)=2))) then x:=x else begin inc(r);  end;
         end;
  writeln(r);

end.

program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

function IsB(a, b, c, d: Integer): Boolean;
const
  coords: array [1..8, 1..2] of Integer = ((1, 2), (-1, 2), (1, -2), (-1, -2),
                                           (2, 1), (-2, 1), (2, -1), (-2, -1));
var
  I: Integer;
begin
  Result := False;
  for I := 1 to 8 do
    if (a + coords[i, 1] = c) and (b + coords[i, 2] = d) then
      begin
        Result := True;
        exit;
      end;
end;

var
  posx1, posy1, posx2, posy2: Integer;
  i, j: Integer;
  C: Char;
  cnt: Integer;

begin
  read(C); posx1 := ord(C)-ord('a')+1;
  read(C); posy1 := StrToInt(C);
  readln;
  read(C); posx2 := ord(C)-ord('a')+1;
  read(C); posy2 := StrToInt(C);
  cnt := 0;
  for I := 1 to 8 do
    for j := 1 to 8 do
      if ((i <> posx1) or (j <> posy1)) and
         ((i <> posx2) or (j <> posy2)) and
         (not isb(i, j, posx1, posy1)) and
         (not isb(i, j, posx2, posy2)) and
         (posx1 <> i) and (posy1 <> j) then
          Inc(Cnt);
  writeln(cnt);
  readln;
  readln;
end.

{$R+,S+,Q+,I+,O-}
{R-,S-,Q-,I-,O+}
var
  ans,x1,y1,x2,y2,x3,y3: longint;

procedure get(var x:longint);
var
  ch: char;
begin
  read(ch);
  while not (ch in ['a'..'h']) do read(ch);
  x:=Ord(ch)-96;
end;

begin
//  assign(input,'in'); reset(input);
//  assign(output,'out'); rewrite(output);
  get(x1); read(y1);
  get(x2); read(y2);
  ans:=0;
  for x3:=1 to 8 do
    for y3:=1 to 8 do
      if (x1 <> x3) and (y1 <> y3) then
        if sqr(x1-x3)+sqr(y1-y3) <> 5 then
          if sqr(x2-x3)+sqr(y2-y3) <> 5 then inc(ans);
  writeln(ans-1);
  close(input);
  close(output);
end.

program kon;
var l,k,s:string;
    x,lx,kx,ly,ky,y,n:integer;
    flag:boolean;
begin
  readln(input,l);
  readln(input,k);
  lx:=ord(l[1]);
  ly:=ord(l[2])-ord('0');
  kx:=ord(k[1]);
  ky:=ord(k[2])-ord('0');
  n:=0;

  for x:=ord('a') to ord('h') do
  begin
    for y:=1 to 8 do
    begin
      flag:=true;
      if (x=lx) or (y=ly) then flag:=false;
      if (x=kx) and (y=ky) then flag:=false;
      if (abs(x-kx)=1) and (abs(y-ky)=2) then flag:=false;
      if (abs(x-kx)=2) and (abs(y-ky)=1) then flag:=false;
      if (abs(x-lx)=1) and (abs(y-ly)=2) then flag:=false;
      if (abs(x-lx)=2) and (abs(y-ly)=1) then flag:=false;
      if flag then n:=n+1;
    end;
  end;

  write(output,n);
end.

const fi='';
        fo='';
        cx:array[1..8]of shortint=(1,1,-1,-1,2,2,-2,-2);
        cy:array[1..8]of shortint=(2,-2,2,-2,1,-1,1,-1);
var
        f:text;
        s1,s2:string;
        x1,y1,x2,y2,i,j,x,h,k,sl:longint;
        v:array[1..8,1..8]of boolean;
begin
        assign(f,fi);
        reset(f);
        readln(f,s1);
        readln(f,s2);
        close(f);
        x1:=ord(s1[1])-ord('a')+1;
        y1:=ord(s1[2])-ord('0');
        x2:=ord(s2[1])-ord('a')+1;
        y2:=ord(s2[2])-ord('0');
        fillchar(v,sizeof(v),false);
        for i := 1 to 8 do
        begin
                v[i][y1]:=true;
                v[x1][i]:=true;
        end;
        v[x2][y2]:=true;
        for i := 1 to 8 do
        begin
                h:=x2+cx[i];
                k:=y2+cy[i];
                if(h>=1)and(h<=8)and(k>=1)and(k<=8)then
                        v[h][k]:=true;
        end;
        sl:=0;
        for i := 1 to 8 do
                for j := 1 to 8 do
                        if(v[i][j]=false)then
                        begin
                                inc(sl);
                                for x := 1 to 8 do
                                begin
                                        h:=i+cx[x];
                                        k:=j+cy[x];
                                        if((h=x1)and(k=y1))or((h=x2)and(k=y2))then
                                        begin
                                                dec(sl);
                                                break;
                                        end;
                                end;
                        end;
        assign(f,fo);
        rewrite(f);
        writeln(f,sl);
        close(f);
end.

program ochered;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var mass: array [-8..8, -8..8] of longint;
    i, j, q: longint;
    a: char;

begin
 readln(a, i);
 mass[9-i, ord(a)-ord('a')+1]:= 2;
 for j:= 1 to 8 do
  if mass[9-i, j] <> 2 then mass[9-i, j]:= 1;
 for j:= 1 to 8 do
  if mass[j, ord(a)-ord('a')+1] <> 2 then mass[j, ord(a)-ord('a')+1]:= 1;
 readln(a, i);
 j:= ord(a)-ord('a')+1;
 q:= 9-i;
 mass[q, j]:= 2;
 mass[q-2, j-1]:= 1;
 mass[q-2, j+1]:= 1;
 mass[q-1, j-2]:= 1;
 mass[q-1, j+2]:= 1;
 mass[q+1, j-2]:= 1;
 mass[q+1, j+2]:= 1;
 mass[q+2, j-1]:= 1;
 mass[q+2, j+1]:= 1;
 i:= 0;
 for q:= 1 to 8 do
  for j:= 1 to 8 do
   if (mass[q, j] = 0) and
      (mass[q-2, j-1]<> 2) and
      (mass[q-2, j+1]<> 2) and
      (mass[q-1, j-2]<> 2) and
      (mass[q-1, j+2]<> 2) and
      (mass[q+1, j-2]<> 2) and
      (mass[q+1, j+2]<> 2) and
      (mass[q+2, j-1]<> 2) and
      (mass[q+2, j+1]<> 2) then inc(i);
 write(i);
end.

{$mode objfpc}

const           InputFile               =       'problemB.inp';
                dX                      :       array ['a' .. 'h'] of integer = ( 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 );
                dY                      :       array ['1' .. '8'] of integer = ( 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 );

type            TPosition               =       record
                        x , y           :       integer;
                end;

var             rook , knight           :       TPosition;
                d                       :       array [1 .. 8 , 1 .. 8] of boolean;
                res                     :       integer;
                i , j                   :       integer;
                ss                      :       string[2];

procedure push( x , y : integer );
        begin
                if ( x > 0 ) and ( y > 0 ) and ( x < 9 ) and ( y < 9 ) and d[x][y] then
                        d[x][y] := false;
        end;

procedure Find( x , y : integer );
        begin
                d[x][y] := false;
                push( x + 2 , y + 1 );
                push( x - 2 , y + 1 );
                push( x + 2 , y - 1 );
                push( x - 2 , y - 1 );
                push( x + 1 , y + 2 );
                push( x - 1 , y + 2 );
                push( x + 1 , y - 2 );
                push( x - 1 , y - 2 );
        end;

begin
                readln( ss );
                rook.x := dX[ss[1]]; rook.y := dY[ss[2]];
                readln( ss );
                knight.x := dX[ss[1]]; knight.y := dY[ss[2]];
                fillchar( d , sizeof( d ) , true );
                for i := 1 to 8 do
                        begin
                                d[rook.x][i] := false;
                                d[i][rook.y] := false;
                        end;
                Find( rook.x , rook.y );
                Find( knight.x , knight.y );
                for i := 1 to 8 do
                for j := 1 to 8 do
                if d[i][j] then
                        inc( res );
                writeln( res );
end.

var
 s,s1:string;
 o,p,x,y,x1,y1,i,j,l,o1,p1:longint;
begin
  readln(s);
  read(s1);
  x:=ord(s[1])-ord('a')+1;
  y:=ord(s[2])-ord('0');
  x1:=ord(s1[1])-ord('a')+1;
  y1:=ord(s1[2])-ord('0');
  for i:=1 to 8 do
   for j:=1 to 8 do
    begin
    o:=abs(i-x1);
    p:=abs(j-y1);
    o1:=abs(i-x);
    p1:=abs(j-y);
    if (i<>x) and (j<>y) then if o+p<>0 then
    if (o=1) and (p=2) then continue
                       else if (p=1) and (o=2) then continue
                 else if (o1=1) and (p1=2) then continue
                       else if (p1=1) and (o1=2) then continue else inc(l);
    end;
  write(l);
end.

program s;

{$APPTYPE CONSOLE}

uses
  SysUtils;

const
d1:array[1..8] of integer=(2,1,-2,-1, 2, 1,-1,-2);
d2:array[1..8] of integer=(1,2, 1, 2,-1,-2,-2,-1);

var a:array[-1..10,-1..10] of integer;
res,ans,i,k,j,cl1,cl2,ck1,ck2:integer;
s1,s2:string;

begin
ans:=0;
readln(s1);
cl1:=ord(s1[1])-ord('a')+1;
cl2:=ord(s1[2])-ord('0');
readln(s2);
ck1:=ord(s2[1])-ord('a')+1;
ck2:=ord(s2[2])-ord('0');

//writeln(cl1,cl2);
//writeln(ck1,ck2);

for I := -1 to 10 do
for j := -1 to 10 do
a[i,j]:=0;

for I := 1 to 8 do
  begin
  a[cl1,i]:=6;
  a[i,cl2]:=6;
  end;

for I := 1 to 8 do
  a[ck1+d1[i],ck2+d2[i]]:=6;

  a[cl1,cl2]:=1;

  a[ck1,ck2]:=1;

for I := 1 to 8 do
begin
for j := 1 to 8 do
//write(a[i,j]);
//writeln;
end;

for I := 1 to 8 do
for j := 1 to 8 do
if a[i,j]=0 then
begin
res:=0;

for k := 1 to 8 do
if (a[i+d1[k],j+d2[k]]=1) then
inc(res);

if res=0 then
inc(ans);

end;

writeln(ans);

end.

program Project3;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var
  st, st1: string;
  x1, y1, x2, y2, x3, y3, chet, i, j, temp: integer;
  yes : boolean;
function lad(x, y, i, j: integer): boolean;
begin
  if (x = i) or (y = j) then
  lad := true
  else lad := false;
end;
function kon(x, y, i, j: integer): boolean;
var h, v : integer;
begin
  h := abs(x-i);
  v := abs(y-j);
  if (h * v =2) then kon := true
  else kon := false;
end;
function perevod(c: char): integer;
begin
  if (c = 'a') then result := 1
  else if (c = 'b') then result := 2
       else if (c = 'c') then result := 3
            else if (c = 'd') then result := 4
            else if (c = 'e') then result := 5
  else if (c = 'f') then result := 6
       else if (c = 'g') then result := 7
            else if (c = 'h') then result := 8;

end;
begin
  readln(st);
  readln(st1);
  chet :=  0;
  val(st[2], y1, temp);
  x1 := perevod(st[1]);
  val(st1[2], y2, temp);
  x2 := perevod(st1[1]);
  for x3 := 1 to 8 do
    for y3 := 1 to 8 do
      begin
        yes := false;
        if (x3 = x1) and (y3 = y1) then continue;
        if (x3 = x2) and (y3 = y2) then continue;
        if (kon(x3, y3, x1, y1)) then yes := true;
        if (kon(x3, y3, x2, y2)) then yes := true;
        if (lad(x1, y1, x3, y3)) then yes := true;
        if (kon(x2,y2,x3,y3)) then yes := true;
        if (not(yes)) then inc(chet);
      end;
    writeln(chet);
  readln;readln;
end.

const
v:array[1..8,1..2] of integer=((-2,-1),(-2,1),(-1,2),(1,2),(2,1),(2,-1),(1,-2),(-1,-2));
var
arr:array[-2..10,-2..10] of boolean;
i,j,n,p:longint;
car:char;
begin
        read (car);
        readln(n);
        for i:=1 to 8 do
                arr[(ord(car)-96+v[i,1]),(n+v[i,2])]:=true;
        for i:=1 to 8 do
                arr[i,n]:=true;
        for i:=1 to 8 do
                arr[(ord(car)-96),i]:=true;
        read (car);
        readln (n);
        arr[(ord(car)-96),n]:=true;
        for i:=1 to 8 do
                arr[(ord(car)-96+v[i,1]),(n+v[i,2])]:=true;
        p:=0;
        for i:=1 to 8 do
                for j:=1 to 8 do
                        if not arr[i,j] then
                                inc (p);
        writeln (p);
end.

{$APPTYPE CONSOLE}
{$R-,Q-}
var
 i,j,chet,k,l : longint;
 a : array [-2..12,-2..12] of boolean;
 c : char;
begin
{ reset(input,'input.txt');
 rewrite(output,'output.txt');   }
 read(c);
 i:=ord(c)-ord('a')+1;
 read(c);
 j:=ord(c)-48;
 k:=i;
 l:=j;
 for I:=k to 8 do
  a[i,l]:=true;
 for i:=1 to k do
  a[i,l]:=true;
 for j:=1 to l do
  a[k,j]:=true;
 for j:=l to 8 do
  a[k,j]:=true;
 read(c);
 read(c);
 read(c);
 i:=ord(c)-ord('a')+1;
 read(c);
 j:=ord(c)-48;
 a[i,j]:=true;
 a[i+2,j+1]:=true;
 a[i+1,j+2]:=true;
 a[i+2,j-1]:=true;
 a[i+1,j-2]:=true;
 a[i-2,j+1]:=true;
 a[i-1,j+2]:=true;
 a[i-2,j-1]:=true;
 a[i-1,j-2]:=true;
 for I:=1 to 8 do
  for j:=1 to 8 do
   if not a[i,j] and not ((i+2=k) and (j+1=l))and not ((i+1=k) and (j+2=l))and not ((i+2=k) and (j-1=l))and not ((i+1=k) and (j-2=l))and not ((i-2=k) and (j+1=l))and not ((i-1=k) and (j+2=l))and not ((i-2=k) and (j-1=l))and not ((i-1=k) and (j-2=l)) then
    inc(chet);
 write(chet);
end.

Var
  s:string;
  ans,x1,x2,y1,y2,i,j:longint;
  p:integer;
 function ok(xx,yy:longint):boolean;
     begin
       if  ((xx<>x1)or(yy<>y1))
       and ((xx<>x2)or(yy<>y2))
       and ((x1<>xx)and(y1<>yy))
       and ((abs(x1-xx)<>2)or(abs(yy-y1)<>1))
       and ((abs(x1-xx)<>1)or(abs(yy-y1)<>2))
       and ((abs(x2-xx)<>2)or(abs(yy-y2)<>1))
       and ((abs(x2-xx)<>1)or(abs(yy-y2)<>2)) then ok:=true
       else ok:=false;
     end;
  Begin
    Readln(s);
    val(s[2],x1,p);
    y1:=ord(s[1])-96;
    Readln(s);
    val(s[2],x2,p);
    y2:=ord(s[1])-96;
    ans:=0;
    for i:=1 to 8 do
      for j:=1 to 8 do
        if ok(i,j) then inc(ans);
      Writeln(ans);
  End.

//Yerzhan Dyussenaliyev
const
	dx: array [1..8] of longint = (-2, -1, 1, 2, 2, 1, -1, -2);
	dy: array [1..8] of longint = (1, 2, 2, 1, -1, -2, -2, -1);
var
	a: array [-10..10, -10..10] of boolean;
	ch, ch1: char;
	x1, y1, x2, y2, i, j, ans: longint;

procedure check(x, y: longint);
var
	i, r: longint;
begin
	if (x1 = x) or (y1 = y) then exit;
	r := 0;
	for i := 1 to 8 do if not a[x + dx[i], y + dy[i]] then inc(r);
	if r = 8 then inc(ans);
end;

begin
//    reset(input, 'a.in');
//    rewrite(output, 'a.out');

	readln(ch, ch1);
    x1 := ord(ch) - 96;
    y1 := ord(ch1) - 48;
	readln(ch, ch1);
    x2 := ord(ch) - 96;
    y2 := ord(ch1) - 48;

	fillchar(a, sizeof(a), 0);

	a[x1, y1] := true;
	a[x2, y2] := true;

	ans := 0;
	for i := 1 to 8 do
	    for j := 1 to 8 do
	        if not a[i, j] then check(i, j);

	writeln(ans);
end.

Type tm=Array [-1..10,-1..10] of Byte;
Var m:tm;
    k1,k2,l1,l2,i,j,kol:Integer;
    c:Char;

Procedure BitoLad;
Begin
     For I:=1 to 8 do
     Begin
          m[i,l2]:=1;
          m[l1,i]:=1;
     End;
     m[l1,l2]:=2;
End;

Procedure Kon (i,j:Integer);
Type td=Array [1..8] of Integer;
Const dx:td=(1,1,-1,-1,2,2,-2,-2);
      dy:td=(2,-2,2,-2,1,-1,-1,1);
Var k:Integer;
Begin
     For k:=1 to 8 do
     Begin
          If m[i+dx[k],j+dy[k]]=0
          then m[i+dx[k],j+dy[k]]:=1
     End;
End;

Begin
     For I:=1 to 8 do
     For J:=1 to 8 do
     m[i,j]:=0;

     Readln (c,l1);
     l2:=ord (c)-96;
     Readln (c,k1);
     k2:=ord (c)-96;
     m[k1,k2]:=3;
     BitoLad;
     Kon (k1,k2);
     Kon (l1,l2);
     kol:=0;
     For I:=1 to 8 do
     For J:=1 to 8 do
     If m[i,j]=0
     then Inc (kol);
     Writeln (kol);
End.

var s:string[2]; a:array[1..8,1..8] of boolean; i,j,n:byte;
begin
        fillchar(a,sizeof(a),true);
        readln(s);
        j:=ord(s[2])-48; n:=15;
        for i:=1 to 8 do a[i,j]:=false;
        i:=ord(s[1])-96;
        fillchar(a[i],sizeof(a[i]),false);
        if i>2 then
        begin
                if j>1 then
                begin
                        inc(n);
                        a[i-2,j-1]:=false
                end;
                if j<8 then
                begin
                        inc(n);
                        a[i-2,j+1]:=false
                end
        end;
        if j<7 then
        begin
                if i>1 then
                begin
                        inc(n);
                        a[i-1,j+2]:=false
                end;
                if i<8 then
                begin
                        inc(n);
                        a[i+1,j+2]:=false
                end
        end;
        if i<7 then
        begin
                if j>1 then
                begin
                        inc(n);
                        a[i+2,j-1]:=false
                end;
                if j<8 then
                begin
                        inc(n);
                        a[i+2,j+1]:=false
                end
        end;
        if j>2 then
        begin
                if i>1 then
                begin
                        inc(n);
                        a[i-1,j-2]:=false
                end;
                if i<8 then
                begin
                        inc(n);
                        a[i+1,j-2]:=false
                end
        end;
        read(s);
        i:=ord(s[1])-96; j:=ord(s[2])-48; a[i,j]:=false;
        inc(n);
        if i>2 then
        begin
                if (j>1) and a[i-2,j-1] then
                begin
                        inc(n);
                        a[i-2,j-1]:=false
                end;
                if (j<8) and a[i-2,j+1] then
                begin
                        inc(n);
                        a[i-2,j+1]:=false
                end
        end;
        if j<7 then
        begin
                if (i>1) and a[i-1,j+2] then
                begin
                        inc(n);
                        a[i-1,j+2]:=false
                end;
                if (i<8) and a[i+1,j+2] then
                begin
                        inc(n);
                        a[i+1,j+2]:=false
                end
        end;
        if i<7 then
        begin
                if (j>1) and a[i+2,j-1] then
                begin
                        inc(n);
                        a[i+2,j-1]:=false
                end;
                if (j<8) and a[i+2,j+1] then
                begin
                        inc(n);
                        a[i+2,j+1]:=false
                end
        end;
        if j>2 then
        begin
                if (i>1) and a[i-1,j-2] then
                begin
                        inc(n);
                        a[i-1,j-2]:=false
                end;
                if (i<8) and a[i+1,j-2] then
                begin
                        inc(n);
                        a[i+1,j-2]:=false
                end
        end;
        write(64-n)
end.

const dx:array[1..8] of longint=(-2,-2,-1,-1,2,2,1,1);
      dy:array[1..8] of longint=(-1,+1,-2,+2,-1,+1,-2,+2);

var kol,x,y,x1,y1,x2,y2,i,kl,j,k,l,m,n:longint;
    a,s,st:string;
    b:array[-1..10,-1..10] of longint;

Function vvod(s:string):longint;
 Begin
  for i:=1 to 8 do
   if s[1]=a[i] then x:=i;
  val(s[2],y,kl);
 End;

BEGIN
 a:='abcdefgh';

 readln(st);
 vvod(st);
 x1:=x;y1:=y;
 readln(st);
 vvod(st);
 x2:=x;y2:=y;

 b[x1,y1]:=1;
 for i:=1 to 8 do
  begin b[x1,i]:=1; b[i,y1]:=1; end;
 b[x2,y2]:=1;
 for i:=1 to 8 do
  b[x2+dx[i],y2+dy[i]]:=1;
 for i:=1 to 8 do
  b[x1+dx[i],y1+dy[i]]:=1;

 kol:=0;
 for i:=1 to 8 do
  for j:=1 to 8 do
   if b[i,j]=0 then inc(kol);
 writeln(kol);

END.

program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var x1,y1,x2,y2,i,j,k,c,n : integer;
ch : char;
mass : array[-2..11,-2..11] of integer;
begin
 // reset(input, 'input.txt');
 // rewrite(output,'output.txt');
  for i := -2 to 11 do
    for j := -2 to 11 do
      mass[i][j] := 0;

  read(ch);
  x1 := ord(ch)-ord('a')+1;
  readln(y1);
  read(ch);
  x2 := ord(ch)-ord('a')+1;
  readln(y2);
  for i := -1 to 9 do begin
    mass[x1][i] := 1;
    mass[i][y1] := 1;
  end;
    mass[x1][y1] := 2;
  mass[x2][y2] := 2;
  mass[x2-2][y2-1] := 1;
  mass[x2-2][y2+1] := 1;
  mass[x2+2][y2-1] := 1;
  mass[x2+2][y2+1] := 1;

  mass[x2-1][y2-2] := 1;
  mass[x2-1][y2+2] := 1;
  mass[x2+1][y2-2] := 1;
  mass[x2+1][y2+2] := 1;
  c := 0;
  for i := 1 to 8 do begin
    for j := 1 to 8 do begin
      if (mass[i][j] = 0) and (mass[i-2][j-1] <> 2) and(mass[i-2][j+1] <> 2) and(mass[i+2][j-1] <> 2) and(mass[i+2][j+1] <> 2) and    (mass[i-1][j-2] <> 2) and(mass[i-1][j+2] <> 2) and(mass[i+1][j-2] <> 2) and(mass[i+1][j+2] <> 2) then
        inc(c);
    end;
  end;
  writeln(c);
end.

{$R+,Q+,I+}
{$apptype console}
Uses SysUtils;
Var
   x:Array['a'..'z'] of Integer;
   c1,c2,c:Char;
   a:Array[1..8,1..8] of Boolean;
   x1,x2,y1,y2,i,j,ans:Integer;
Begin
   i:=0;
   For c:='a' To 'z' Do Begin
      i:=i+1;
      x[c]:=i;
   End;
   Read(c1);
   Read(c2);
   ReadLn;
   a[x[c1],strtoint(c2)]:=true;
   x1:=x[c1];
   y1:=strtoint(c2);
   Read(c1);
   Read(c2);
   a[x[c1],strtoint(c2)]:=true;
   x2:=x[c1];
   y2:=strtoint(c2);
   For i:=1 To 8 Do a[i,y1]:=true;
   For i:=1 To 8 Do a[x1,i]:=true;
   If (x2>1) and (y2>2) Then a[x2-1,y2-2]:=true;
   If (x2>1) and (y2<7) Then a[x2-1,y2+2]:=true;
   If (x2>2) and (y2>1) Then a[x2-2,y2-1]:=true;
   If (x2>2) and (y2<8) Then a[x2-2,y2+1]:=true;
   If (x2<7) and (y2>1) Then a[x2+2,y2-1]:=true;
   If (x2<7) and (y2<8) Then a[x2+2,y2+1]:=true;
   If (x2<8) and (y2>2) Then a[x2+1,y2-2]:=true;
   If (x2<8) and (y2<7) Then a[x2+1,y2+2]:=true;
   If (x1>1) and (y1>2) Then a[x1-1,y1-2]:=true;
   If (x1>1) and (y1<7) Then a[x1-1,y1+2]:=true;
   If (x1>2) and (y1>1) Then a[x1-2,y1-1]:=true;
   If (x1>2) and (y1<8) Then a[x1-2,y1+1]:=true;
   If (x1<7) and (y1>1) Then a[x1+2,y1-1]:=true;
   If (x1<7) and (y1<8) Then a[x1+2,y1+1]:=true;
   If (x1<8) and (y1>2) Then a[x1+1,y1-2]:=true;
   If (x1<8) and (y1<7) Then a[x1+1,y1+2]:=true;
   ans:=0;
   For i:=1 To 8 Do
      For j:=1 To 8 Do
         If not(a[i,j]) Then ans:=ans+1;
   Write(ans);
End.

program solution;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  s1, s2 : string;
  ans, x1, y1, x2, y2, i, j : integer;
  used : array[0..9, 0..9] of boolean;

begin
  //reset(input, 'input.txt');
  //rewrite(output, 'output.txt');
  readln(s1);
  readln(s2);
  x1 := 9 - ord(s1[2]) + ord('0');
  y1 := ord(s1[1]) - ord('a') + 1;
  x2 := 9 - ord(s2[2]) + ord('0');
  y2 := ord(s2[1]) - ord('a') + 1;
  used[x1, y1] := true;
  used[x2, y2] := true;
  ans := 0;
  for i := 1 to 8 do
    for j := 1 to 8 do
      if not used[i, j] then begin
        if (i = x1) or (j = y1) or ((abs(i - x2) > 0) and (abs(j - y2) > 0) and (abs(i - x2) + abs(j - y2) = 3)) or ((abs(i - x1) > 0) and (abs(j - y1) > 0) and (abs(i - x1) + abs(j - y1) = 3)) then
          continue;
        inc(ans);
      end;
  write(ans);
end.

const
  maxn = 96;
  x: array[1..8] of integer = (-1, -2, 2, 1, -1, -2, 1, 2);
  y: array[1..8] of integer = (-2, -1, 1, 2, 2, 1, -2, -1);

var
  boo: array[-10..18, -10..18] of boolean;
  l, t, x1, x2, y1, y2, i, j: longint;
  ch1, ch2: char;

function correct1: boolean;
begin
  for l := 1 to 8 do
    if ((x[l] + i = x1) and (y[l] + j = y1)) or ((x[l] + i = x2) and (y[l] + j = y2))then begin
      correct1 := false;
      exit;
    end;
  if (i = x1) or (j = y1) then correct1 := false
  else
    correct1 := true;
end;

function correct: boolean;
begin
  if (x[i] + x2 > 0) and (x[i] + x2 <= 8) and (y[i] + y2 > 0) and (y[i] + y2 <= 8) then
    correct := true
  else
    correct := false;
end;

procedure horse;
begin
  for i := 1 to 8 do
    if correct then
      boo[x2 + x[i], y2 + y[i]] := true;
end;

procedure readchar;
begin
  readln(ch1, ch2);
  x1 := ord(ch1) - maxn;
  val(ch2, y1);
  read(ch1, ch2);
  x2 := ord(ch1) - maxn;
  val(ch2, y2);
  boo[x1, y1] := true;
  boo[x2, y2] := true;
end;

begin
  readchar;
  horse;
  for i := 1 to 8 do
    for j := 1 to 8 do
      if (not boo[i, j]) and (correct1) then
        inc(t);
  write(t);
end.

const fi='';
        fo='';
        cx:array[1..8]of shortint=(1,1,-1,-1,2,2,-2,-2);
        cy:array[1..8]of shortint=(2,-2,2,-2,1,-1,1,-1);
var
        f:text;
        s1,s2:string;
        x1,y1,x2,y2,i,j,x,h,k,sl:longint;
        v:array[1..8,1..8]of boolean;
begin
        assign(f,fi);
        reset(f);
        readln(f,s1);
        readln(f,s2);
        close(f);
        x1:=ord(s1[1])-ord('a')+1;
        y1:=ord(s1[2])-ord('0');
        x2:=ord(s2[1])-ord('a')+1;
        y2:=ord(s2[2])-ord('0');
        fillchar(v,sizeof(v),false);
        for i := 1 to 8 do
        begin
                v[i][y1]:=true;
                v[x1][i]:=true;
        end;
        v[x2][y2]:=true;
        for i := 1 to 8 do
        begin
                h:=x2+cx[i];
                k:=y2+cy[i];
                if(h>=1)and(h<=8)and(k>=1)and(k<=8)then
                        v[h][k]:=true;
        end;
        sl:=0;
        for i := 1 to 8 do
                for j := 1 to 8 do
                        if(v[i][j]=false)then
                        begin
                                inc(sl);
                                for x := 1 to 8 do
                                begin
                                        h:=i+cx[x];
                                        k:=j+cy[x];
                                        if((h=x1)and(k=y1))or((h=x2)and(k=y2))then
                                        begin
                                                dec(sl);
                                                break;
                                        end;
                                end;
                        end;
        assign(f,fo);
        rewrite(f);
        writeln(f,sl);
        close(f);
end.

program b1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  s:string;
  x,y,x1,y1,i,j,r:longint;

begin
  readln(s);
  x:=ord(s[1])-ord('a')+1;
  y:=ord(s[2])-ord('0');
  readln(s);
  x1:=ord(s[1])-ord('a')+1;
  y1:=ord(s[2])-ord('0');
  r:=0;
  for i:=1 to 8 do
    for j:=1 to 8 do
       if (i<>x)and(j<>y)and((x1<>i)or(y1<>j)) then
         begin
           if (((abs(i-x1)=2)and(abs(j-y1)=1))or
              ((abs(i-x1)=1)and(abs(j-y1)=2)))or
              (((abs(i-x)=2)and(abs(j-y)=1))or
              ((abs(i-x)=1)and(abs(j-y)=2))) then x:=x else begin inc(r);  end;
         end;
  writeln(r);

end.

{$R+,O-}
Uses Math;
Const
 inf = maxlongint;
Type
 int = longint; bool = boolean;
Var
	ans ,x ,y ,x1 ,y1 ,code ,i ,j	:	int;
	s	:	string;
	a	:	array [-3..12,-3..12] of bool;
Begin
{	Reset(input,'a.in');
	Rewrite(output,'a.out');}
	Readln(s);
	x := ord(s[1]) - ord('a') + 1;
	val(s[2] ,y ,code);

	Readln(s);
	x1 := ord(s[1]) - ord('a') + 1;
	val(s[2] ,y1 ,code);
        a[x ,y] := true;

	For i := 1 to 8 do
		a[x ,i] := true;

	For i := 1 to 8 do
		a[i ,y] := true;

        a[x1 ,y1] := true;
	a[x1+2 ,y1+1] := true;
	a[x1+1 ,y1+2] := true;
	a[x1-2 ,y1+1] := true;
	a[x1+1 ,y1-2] := true;
	a[x1+2 ,y1-1] := true;
	a[x1-1 ,y1+2] := true;
	a[x1-2 ,y1-1] := true;
	a[x1-1 ,y1-2] := true;

	For i := 1 to 8 do
	For j := 1 to 8 do Begin
		If (not a[i ,j]) and not((i + 2 = x) and (j + 1 = y)) and not(((i + 1 = x) and (j + 2 = y))) and not((i - 2 = x) and (j + 1 = y)) and not((i + 1 = x) and (j - 2 = y)) and not((i + 2 = x) and (j - 1 = y)) and not((i - 1 = x) and (j + 2 = y)) and not((i - 2 = x) and (j - 1 = y)) and not((i - 1 = x) and (j - 2 = y)) and not((i + 2 = x) and (j + 1 = y)) and not(((i + 1 = x) and (j + 2 = y))) and not((i - 2 = x) and (j + 1 = y)) and not((i + 1 = x1) and (j - 2 = y1)) and not((i + 2 = x1) and (j - 1 = y1)) and not((i - 1 = x1) and (j + 2 = y1)) and not((i - 2 = x1) and (j - 1 = y1)) and not((i - 1 = x1) and (j - 2 = y1)) then
			inc(ans);
	End;

	write(ans);
End.

program Project2;

{$APPTYPE CONSOLE}

var
  kx,ky,lx,ly,i,j,k:integer;
  t:char;
  a:array[-3..11,-3..11] of boolean;

begin
  for i:=1 to 8 do
    for j:=1 to 8 do
    a[i,j]:=true;
  read(t);
  lx:=ord(t)-96;
  readln(t);
  ly:=ord(t)-48;
  read(t);
  kx:=ord(t)-96;
  readln(t);
  ky:=ord(t)-48;
  a[kx,ky]:=false;
  a[lx,ly]:=false;
  for i:=1 to 8 do
  begin
    a[lx,i]:=false;
    a[i,ly]:=false;
  end;
  a[kx+2,ky+1]:=false;
  a[kx+2,ky-1]:=false;
  a[kx-1,ky+2]:=false;
  a[kx+1,ky+2]:=false;
  a[kx-2,ky+1]:=false;
  a[kx-2,ky-1]:=false;
  a[kx-1,ky-2]:=false;
  a[kx+1,ky-2]:=false;
    a[lx+2,ly+1]:=false;
  a[lx+2,ly-1]:=false;
  a[lx-1,ly+2]:=false;
  a[lx+1,ly+2]:=false;
  a[lx-2,ly+1]:=false;
  a[lx-2,ly-1]:=false;
  a[lx-1,ly-2]:=false;
  a[lx+1,ly-2]:=false;

  k:=0;

  for i:=1 to 8 do
    for j:=1 to 8 do
    if  a[i,j] then k:=k+1;

writeln(k);

end.

var sum,i,j:longint;
    s:string;
    q,h:array [1..2] of longint;
    b:array [-2..11,-2..11] of boolean;
function f(i,j:longint):boolean;
begin
  f:=true;
  if (i<=0)or(j<=0)or(i>=9)or(j>=9) then exit;
  if b[i,j] then exit
  else f:=false;
end;
begin
  readln(s);
  q[1]:=ord(s[1])-96;
  q[2]:=ord(s[2])-48;
  readln(s);
  h[1]:=ord(s[1])-96;
  h[2]:=ord(s[2])-48;
  fillchar(b,sizeof(b),true);
  for i:=1 to 8 do
    begin
      b[q[1],i]:=false;
      b[i,q[2]]:=false;
    end;
  b[q[1],q[2]]:=false;
  b[h[1],h[2]]:=false;
  b[h[1]+1,h[2]+2]:=false;
  b[h[1]-1,h[2]+2]:=false;
  b[h[1]+1,h[2]-2]:=false;
  b[h[1]-1,h[2]-2]:=false;
  b[h[1]+2,h[2]+1]:=false;
  b[h[1]-2,h[2]+1]:=false;
  b[h[1]+2,h[2]-1]:=false;
  b[h[1]-2,h[2]-1]:=false;
  sum:=0;
  for i:=-2 to 11 do
    for j:=-2 to 0 do
      begin
        b[i,j]:=true;
        b[j,i]:=true;
      end;
  for i:=-2 to 11 do
    for j:=9 to 11 do
      begin
        b[i,j]:=true;
        b[j,i]:=true;
      end;
  for i:=1 to 8 do
    begin
      for j:=1 to 8 do
        begin
          if b[i,j] and
          (sqr(q[1]-i)+sqr(q[2]-j)<>5)
          and(sqr(h[1]-i)+sqr(h[2]-j)<>5)
          then sum:=sum+1;
//          write(ord(b[i,j]),' ');
        end;
//      writeln;
    end;
  writeln(sum);
end.

program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var ch:char;
x1,x2,y1,y2,i,j,ans:integer;
bool:array[-50..50,-50..50] of boolean;

procedure move2(x,y:integer);
begin
  bool[x,y]:=true;
  bool[x+2,y+1]:=true;
  bool[x-2,y+1]:=true;
  bool[x+2,y-1]:=true;
  bool[x-2,y-1]:=true;
  bool[x+1,y+2]:=true;
  bool[x-1,y+2]:=true;
  bool[x+1,y-2]:=true;
  bool[x-1,y-2]:=true;
end;

procedure move1(x,y:integer);
var i,j:integer;
begin
  i:=x;
  j:=y;
  while (i in [1..8]) and (j in [1..8]) and ((i<>x2) or (j<>y2)) do begin
    bool[i,j]:=true;
    inc(i);
  end;
  i:=x;
  j:=y;
  while (i in [1..8]) and (j in [1..8]) and ((i<>x2) or (j<>y2)) do begin
    bool[i,j]:=true;
    dec(i);
  end;
  i:=x;
  j:=y;
  while (i in [1..8]) and (j in [1..8]) and ((i<>x2) or (j<>y2)) do begin
    bool[i,j]:=true;
    inc(j);
  end;
  i:=x;
  j:=y;
  while (i in [1..8]) and (j in [1..8]) and ((i<>x2) or (j<>y2)) do begin
    bool[i,j]:=true;
    dec(j);
  end;
end;

begin
  read(ch);
  x1:=ord(ch)-ord('a')+1;
  readln(y1);
  read(ch);
  x2:=ord(ch)-ord('a')+1;
  readln(y2);
  move1(x1,y1);
  move2(x1,y1);
  move2(x2,y2);
  ans:=0;
  for i:=1 to 8 do
    for j:=1 to 8 do
      if not bool[i,j] then inc(ans);
  writeln(ans);
end.

var     xh,xc,nh,nc,i,j,sum : byte;   // xh la hang cua xe, xc la cot cua xe,....
        s : string[2];
        a : array['a'..'h'] of byte = (1,2,3,4,5,6,7,8);
        b : array['1'..'8'] of byte = (1,2,3,4,5,6,7,8);
begin
        readln(s);
        xh := a[s[1]];
        xc := b[s[2]];
        readln(s);
        nh := a[s[1]];
        nc := b[s[2]];

        sum := 0;
        for i := 1 to 8 do
                for j := 1 to 8 do
                        if  (i<>xh) and (j<>xc)          // tranh con xe giet
                        and ((i<>nh) or (j<>nc))         // khong trung con ngua
                        and (sqr(i-nh) + sqr(j-nc) <> 5) // tranh giet ma and bi ma giet
                        and (sqr(i-xh) + sqr(j-xc) <> 5) // tranh giet con xe
                                then inc(sum);
        writeln(sum);
        readln;
end.

const dx:array[1..8] of shortint=(1,1,2,2,-1,-1,-2,-2);
      dy:array[1..8] of shortint=(-2,2,1,-1,2,-2,1,-1);
var a:array[1..8,'a'..'h'] of byte;
    x1,x2:char;y1,y2:byte;n:integer;
procedure lad;
var i:integer;c:char;
begin
 for i:=1 to 8 do
  a[i,x1]:=1;
 for c:='a' to 'h' do
  a[y1,c]:=1;
 for i:=1 to 8 do
  if (chr(ord(x1)+dx[i])<='h')and
     (chr(ord(x1)+dx[i])>='a')and
     (y1+dy[i]>=1)and(y1+dy[i]<=8)
     then a[y1+dy[i],chr(ord(x1)+dx[i])]:=1;
end;
procedure kon;
var i,y1:integer;c,x1:char;
begin
 x1:=x2;y1:=y2;a[y2,x2]:=1;
 for i:=1 to 8 do
  if (chr(ord(x1)+dx[i])<='h')and
     (chr(ord(x1)+dx[i])>='a')and
     (y1+dy[i]>=1)and(y1+dy[i]<=8)
     then a[y1+dy[i],chr(ord(x1)+dx[i])]:=1;
end;
procedure count;
var i:integer;c:char;
begin
 for i:=1 to 8 do
  for c:='a' to 'h' do
   if a[i,c]=0 then inc(n);
end;
begin
{ assign(input,'input.txt');reset(input);
 assign(output,'output.txt');rewrite(output);}
 read(x1);readln(y1); read(x2);readln(y2);
 lad;
 kon;
 count;
 writeln(n);
end.

const fi = '';
      fo = '';
      f: array['a'..'h'] of longint = (1,2,3,4,5,6,7,8);
var a: array[-1..10,-1..10] of boolean;
    x1, x2: char;
    s: string;
    y1, y2, i, j, ans, e: longint;
begin
  assign(input,fi); reset(input);
  assign(output,fo); rewrite(output);

  fillchar(a,sizeof(a),true);
  readln(x1,s);
  val(s,y1,e);
  readln(x2,s);
  val(s,y2,e);
  a[f[x1],y1]:=false;
  for i:=1 to 8 do
    begin
      a[f[x1],i]:=false;
      a[i,y1]:=false;
    end;

  a[f[x2],y2]:=false;
  a[f[x2]-2,y2-1]:=false;
  a[f[x2]-2,y2+1]:=false;
  a[f[x2]-1,y2-2]:=false;
  a[f[x2]-1,y2+2]:=false;
  a[f[x2]+1,y2-2]:=false;
  a[f[x2]+1,y2+2]:=false;
  a[f[x2]+2,y2-1]:=false;
  a[f[x2]+2,y2+1]:=false;

  a[f[x1],y1]:=false;
  a[f[x1]-2,y1-1]:=false;
  a[f[x1]-2,y1+1]:=false;
  a[f[x1]-1,y1-2]:=false;
  a[f[x1]-1,y1+2]:=false;
  a[f[x1]+1,y1-2]:=false;
  a[f[x1]+1,y1+2]:=false;
  a[f[x1]+2,y1-1]:=false;
  a[f[x1]+2,y1+1]:=false;

  ans:=0;
  for i:=1 to 8 do
    for j:=1 to 8 do if a[i,j] then inc(ans);
  writeln(ans);

  {for i:=1 to 8 do
    begin
      for j:=1 to 8 do if a[i,j] then write('T ')
      else write('F ');
      writeln;
    end;   }

  close(input); close(output);
end.

const
        fi='';
        fo='';
        x:array[1..8] of longint=(-2,-2,-1,-1,1,1,2,2);
        y:array[1..8] of longint=(-1,1,-2,2,-2,2,-1,1);
var
        m:array[-10..10,-10..10] of longint;
        a,b,c,d,i,j,dem:longint;
        s1,s2:string;

procedure doc;
begin
        assign(input,fi);
        reset(input);
        readln(s1);
        readln(s2);
        close(input);
end;

procedure xuly;
begin
        a:=ord(s1[1])-96; b:=ord(s1[2])-48; c:=ord(s2[1])-96; d:=ord(s2[2])-48;
        for i:=1 to 8 do
                begin
                        m[a-x[i],b-y[i]]:=1;
                        m[c-x[i],d-y[i]]:=1;
                        m[a,i]:=1; m[i,b]:=1;
                end;
        for i:=1 to 8 do
                for j:=1 to 8 do
                        if m[i,j]=0 then inc(dem);

end;

procedure ghi;
begin
        assign(output,fo);
        rewrite(output);
        write(dem-1);
        close(output);
end;

begin
        doc;
        xuly;
        ghi;
end.

Var a,b:char;
    q,w,i,j,k,l,ans:longint;
    x:array[1..8] of char;
    c:array[-100..100,-100..100] of boolean;
    Begin
  readln(a,i);
  readln(b,j);
  for q:=1 to 8 do
   for w:=1 to 8 do
    c[q,w]:=true;
  x[1]:='a';
  x[2]:='b';
  x[3]:='c';
  x[4]:='d';
  x[5]:='e';
  x[6]:='f';
  x[7]:='g';
  x[8]:='h';
  for q:=1 to 8 do
   begin
    if a=x[q] then k:=q;
    if b=x[q] then l:=q;
   end;
  c[k,i]:=false;
  c[k+2,i+1]:=false;
  c[k+2,i-1]:=false;
  c[k-2,i+1]:=false;
  c[k-2,i-1]:=false;
  c[k+1,i+2]:=false;
  c[k+1,i-2]:=false;
  c[k-1,i+2]:=false;
  c[k-1,i-2]:=false;
  c[l+2,j+1]:=false;
  c[l+2,j-1]:=false;
  c[l-2,j+1]:=false;
  c[l-2,j-1]:=false;
  c[l+1,j+2]:=false;
  c[l+1,j-2]:=false;
  c[l-1,j-2]:=false;
  c[l-1,j+2]:=false;
  c[l,j]:=false;
  for q:=1 to 8 do
   c[k,q]:=false;
  for q:=1 to 8 do
   c[q,i]:=false;
  for q:=1 to 8 do
   for w:=1 to 8 do
    begin
     if c[q,w] then inc(ans);
    end;
  writeln(ans);
 End.

{$apptype console}
{$R+}
{$O-}

type
    point = record
      x1: char;
      y, x: integer;
    end;

var
    a: array[-5..15, -5..15] of byte;
    l, k: point;
    ans: integer;

procedure tr(v: char; var adr: integer);
begin
    adr := ord(v) - 96;
end;

procedure horse;
begin
    a[k.y, k.x] := 1;
    if (k.y + 2 <= 8) and (k.x + 1 <= 8) then a[k.y + 2, k.x + 1] := 1;
    if (k.y + 1 <= 8) and (k.x + 2 <= 8) then a[k.y + 1, k.x + 2] := 1;
    if (k.y - 1 >= 1) and (k.x + 2 <= 8) then a[k.y - 1, k.x + 2] := 1;
    if (k.y - 2 >= 1) and (k.x + 1 <= 8) then a[k.y - 2, k.x + 1] := 1;
    if (k.y + 2 <= 8) and (k.x - 1 >= 1) then a[k.y + 2, k.x - 1] := 1;
    if (k.y + 1 <= 8) and (k.x - 2 >= 1) then a[k.y + 1, k.x - 2] := 1;
    if (k.y - 1 >= 1) and (k.x - 2 >= 1) then a[k.y - 1, k.x - 2] := 1;
    if (k.y - 2 >= 1) and (k.x - 1 >= 1) then a[k.y - 2, k.x - 1] := 1;
end;

procedure ladya;
var i: integer;
begin
    for i := 1 to 8 do begin
      a[i, l.x] := 1;
      a[l.y, i] := 1;
    end;
end;

function check_horse(y1, x1: integer): byte;
begin
    check_horse := 0;
    if ((y1 + 2 = l.y) and (x1 + 1 = l.x)) or ((y1 + 2 = k.y) and (x1 + 1 = k.x)) then check_horse := 1;
    if ((y1 + 1 = l.y) and (x1 + 2 = l.x)) or ((y1 + 1 = k.y) and (x1 + 2 = k.x)) then check_horse := 1;
    if ((y1 - 2 = l.y) and (x1 + 1 = l.x)) or ((y1 - 2 = k.y) and (x1 + 1 = k.x)) then check_horse := 1;
    if ((y1 + 2 = l.y) and (x1 - 1 = l.x)) or ((y1 + 2 = k.y) and (x1 - 1 = k.x)) then check_horse := 1;
    if ((y1 + 1 = l.y) and (x1 - 2 = l.x)) or ((y1 + 1 = k.y) and (x1 - 2 = k.x)) then check_horse := 1;
    if ((y1 - 1 = l.y) and (x1 - 2 = l.x)) or ((y1 - 1 = k.y) and (x1 - 2 = k.x)) then check_horse := 1;
    if ((y1 - 2 = l.y) and (x1 - 1 = l.x)) or ((y1 - 2 = k.y) and (x1 - 1 = k.x)) then check_horse := 1;
    if ((y1 - 1 = l.y) and (x1 + 2 = l.x)) or ((y1 - 1 = k.y) and (x1 + 2 = k.x)) then check_horse := 1;
end;

procedure solve;
var i, j: integer;
begin
    for i := 1 to 8 do
      for j := 1 to 8 do
        if (a[i, j] = 0) and (check_horse(i, j) = 0) then
          inc(ans);
end;

begin
    //reset(input, 'input.txt');
    //rewrite(output, 'output.txt');
    fillchar(a, sizeof(a), 0); ans := 0;
    readln(l.x1, l.y);
    read(k.x1, k.y);
    tr(l.x1, l.x); tr(k.x1, k.x);
    horse; ladya;
    solve;
    write(ans);
end.

var u:array[-2..10, -2..10] of integer;
a: array[1..4] of integer;
i, n, k, j, m, p, xl, yl, xk, yk: longint;
cl, ck: char;
begin

readln(cl, yl);
read(ck, yk);
xl := ord(cl)-ord('a')+1;
xk := ord(ck) - ord('a')+1;
k := 0;
a[1] := -2;
a[2] := -1;
a[3] := 1;
a[4] := 2;
for i := 1 to 8 do
for j := 1 to 8 do
begin
  m := 1;
  if (i = 2)and(j=3)then
  m := m mod 2;
  if (i = xk)and(j = yk) then m := 0;
  if i = xl then m := 0;
  if j = yl then m := 0;
  for p := 1 to 4 do
  begin
    if i = a[p]+xk then
    if (j = yk + ((abs(a[p])) mod 2) + 1)or
    (j = yk - abs(a[p]) mod 2 - 1) then
    m := 0;
    if i = a[p]+xl then
    if (j = yl + ((abs(a[p])) mod 2) + 1)or
    (j = yl - abs(a[p]) mod 2 - 1) then
    m := 0;

  end;
  k := k + m;
end;
write (k);

end.

program indB;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var ch1, ch2: char;
    y1, y2, x1, x2, f, ans, i, j: integer;
    fl: boolean;
    a: array[-1..10, -1..10] of integer;

begin
  readln(ch1, y1);
  readln(ch2, y2);

  x1:=ord(ch1)-96;
  x2:=ord(ch2)-96;

  fillchar(a, sizeof(a), 0);

  a[x2-2, y2+1]:=1;
  a[x2-2, y2-1]:=1;
  a[x2-1, y2+2]:=1;
  a[x2-1, y2-2]:=1;
  a[x2+1, y2-2]:=1;
  a[x2+1, y2+2]:=1;
  a[x2+2, y2+1]:=1;
  a[x2+2, y2-1]:=1;

  for i:=1 to 8 do
    begin
      a[x1, i]:=1;
      a[i, y1]:=1;
    end;

  a[x1, y1]:=2;
  a[x2, y2]:=2;

  ans:=0;

  for i:=1 to 8 do
    for j:=1 to 8 do
      begin
        if a[i, j]=0 then
          begin
            fl:=true;
            if a[i-2, j+1]=2 then fl:=false;
            if a[i-2, j-1]=2 then fl:=false;
            if a[i-1, j+2]=2 then fl:=false;
            if a[i-1, j-2]=2 then fl:=false;
            if a[i+1, j-2]=2 then fl:=false;
            if a[i+1, j+2]=2 then fl:=false;
            if a[i+2, j+1]=2 then fl:=false;
            if a[i+2, j-1]=2 then fl:=false;
            if fl=true then inc(ans);
          end;

      end;
  writeln(ans);
  readln;

end.

program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var a:array [0..14,0..14] of integer;
    x,x2:Integer;
    s:char;
    kol,i,j:Integer;
    st,s2:string;

begin
  i:=1;
  while i<=2 do
  begin
  Readln(st);
  s:=st[1]; s2:=st[2];
  case s of
   'a': x:=3;
   'b': x:=4;
   'c': x:=5;
   'd': x:=6;
   'e': x:=7;
   'f': x:=8;
   'g': x:=9;
   'h': x:=10;
  end;
  x2:=StrToInt(s2)+2;

  if i=1 then for j:=0 to 12 do begin a[x,j]:=1; a[j,x2]:=1 end;

  a[x,x2]:=1;
  a[x-2,x2+1]:=1;
  a[x-1,x2+2]:=1;
  a[x+2,x2+1]:=1;
  a[x+1,x2+2]:=1;
  a[x-2,x2-1]:=1;
  a[x-1,x2-2]:=1;
  a[x+2,x2-1]:=1;
  a[x+1,x2-2]:=1;
  i:=i+1;
   end;
  kol:=0;
   For i:=3 to 10 do
    for j:=3 to 10 do
       if a[i,j]=0 then inc(kol);

  write(kol);
   Readln;
  { TODO -oUser -cConsole Main : Insert code here }
end.

const
cab:array[1..8,1..2] of longint=((-1,-2),(-2,-1),(-2,1),(-1,2),(1,2),(2,1),(2,-1),(1,-2));
var
arr:array[1..8,1..8] of longint;
usa:array[1..8,1..8] of boolean;
i,j,cont,x,y,k:longint;
cad:string;
bol:boolean;
begin
    readln(cad);
    x:=ord(cad[1])-96;
    y:=ord(cad[2])-48;

    for i:=1 to 8 do
    begin
        arr[x,i]:=1;
        arr[i,y]:=1;
    end;
    arr[x,y]:=3;
    readln(cad);
    x:=ord(cad[1])-96;
    y:=ord(cad[2])-48;
    arr[x,y]:=3;
    for i:=1 to 8 do
    begin
        if (x+cab[i,1]<=8) and (y+cab[i,2]<=8) and (x+cab[i,1]>0) and (y+cab[i,2]>0) then
            arr[x+cab[i,1],y+cab[i,2]]:=2;
    end;
    for i:=1 to 8 do
    begin
        for j:=1 to 8 do
        begin
            bol:=false;
            if arr[i,j]<>0 then
            begin
                bol:=true;
            end;
            for k:=1 to 8 do
            begin
                if (i+cab[k,1]<=8) and (i+cab[k,1]>0) and (j+cab[k,2]>0) and (j+cab[k,2]<=8) and (arr[i+cab[k,1],j+cab[k,2]]=3)   then
                begin
                    bol:=true;
                end;
            end;
            if not bol then
            begin
                cont:=cont+1;
                usa[i,j]:=true;

            end;
        end;
    end;
    writeln(cont);
end.

program Konandladya;

{$APPTYPE CONSOLE}

const
n=8;
var
a : array [1..n,1..n] of 0..3;
s : string;
i,j,ans,x1,y1,x2,y2 : byte;
fl : boolean;
begin
{assign (input,'in.txt');
assign (output,'out.txt');
reset (input);
rewrite (output);}
ans:=0;
readln (s);
x1:=9-ord(s [2])+ord ('0');
y1:=ord (s [1])-ord ('a')+1;
readln (s);
x2:=9-ord(s [2])+ord ('0');
y2:=ord (s [1])-ord ('a')+1;
fillchar (a,sizeof(a),0);
a [x1,y1]:=2;
a [x2,y2]:=1;
for i:=1 to n do
 for j:=1 to n do
 begin
 if (i=x2+1) and ((j=y2+2) or (j=y2-2)) then a [i,j]:=1;
 if (i=x2-1) and ((j=y2+2) or (j=y2-2)) then a [i,j]:=1;
 if (i=x2+2) and ((j=y2+1) or (j=y2-1)) then a [i,j]:=1;
 if (i=x2-2) and ((j=y2+1) or (j=y2-1)) then a [i,j]:=1;
 if ((x1=i) and (y1<>j)) or ((y1=j) and (x1<>i)) then a [i,j]:=2;
 end;
{for i:=1 to n do
begin
 for j:=1 to n do
 write (a [i,j] : 5);
 writeln;
end;}
for i:=1 to n do
 for j:=1 to n do
 if a [i,j]=0 then
 begin
 fl:=true;
 if (x1=i+1) and ((y1=j+2) or (y1=j-2)) then fl:=false;
 if (x1=i-1) and ((y1=j+2) or (y1=j-2)) then fl:=false;
 if (x1=i+2) and ((y1=j+1) or (y1=j-1)) then fl:=false;
 if (x1=i-2) and ((y1=j+1) or (y1=j-1)) then fl:=false;
 if (x2=i+1) and ((y2=j+2) or (y2=j-2)) then fl:=false;
 if (x2=i-1) and ((y2=j+2) or (y2=j-2)) then fl:=false;
 if (x2=i+2) and ((y2=j+1) or (y2=j-1)) then fl:=false;
 if (x2=i-2) and ((y2=j+1) or (y2=j-1)) then fl:=false;
 if fl then inc (ans);
 end;
 write (ans);
end.

{$APPTYPE CONSOLE}

const
  mvx: Array[1..8] of Integer =
  (-2, -2, -1, +1, +2, +2, +1, -1);
  mvy: Array[1..8] of Integer =
  (-1, +1, +2, +2, +1, -1, -2, -2);

var
  ch: Char;
  i, j: Integer;
  l1, l2, k1, k2, k: Integer;
  map: Array[-10..+20, -10..+20] of byte;
  res: Integer;
  fl: Boolean;

begin
  Read(ch); l1 := Ord(ch)-Ord('a') + 1;
  Read(ch); l2 := Ord(ch)-Ord('0');
  ReadLn;
  Read(ch); k1 := Ord(ch)-Ord('a') + 1;
  Read(ch); k2 := Ord(ch)-Ord('0');
  FillChar(map, sizeof(map), 0);
  map[k1, k2] := 2;
  for i := 1 to 8 do
   map[k1+mvx[i]][k2+mvy[i]] := 1;
  for i := -10 to 20 do
  begin
   map[i, l2] := 1;
   map[l1, i] := 1;
  end;
  map[l1, l2] := 2;
  for i := 1 to 8 do
   for j := 1 to 8 do
   if map[i, j] = 0 then
   begin
    fl := True;
    for k := 1 to 8 do
     if map[i+mvx[k]][j+mvy[k]] = 2 then
     begin
      fl := False;
      Break;
     end;
    if fl then res := res + 1;
   end;

   WriteLn(res);
end.

var l,k,s:string;
    x,lx,kx,ly,ky,y,n:integer;
    flag:boolean;
begin
  readln(input,l);
  readln(input,k);
  lx:=ord(l[1]);
  ly:=ord(l[2])-ord('0');
  kx:=ord(k[1]);
  ky:=ord(k[2])-ord('0');
  n:=0;

  for x:=ord('a') to ord('h') do
  begin
    for y:=1 to 8 do
    begin
      flag:=true;
      if (x=lx) or (y=ly) then flag:=false;
      if (x=kx) and (y=ky) then flag:=false;
      if (abs(x-kx)=1) and (abs(y-ky)=2) then flag:=false;
      if (abs(x-kx)=2) and (abs(y-ky)=1) then flag:=false;
      if (abs(x-lx)=1) and (abs(y-ly)=2) then flag:=false;
      if (abs(x-lx)=2) and (abs(y-ly)=1) then flag:=false;
      if flag then n:=n+1;
    end;
  end;

  write(output,n);
end.

{$R+ Q+ I+}
{$APPTYPE CONSOLE}
uses
  Sysutils;
function check(i,j,x,y : integer) : boolean;
var
   t : boolean;
begin
   t := false;
   if (i-1 = x) and (j + 2 = y)  then t := true;
   if (i-1 = x) and (j - 2 = y) then t := true;
   if (i-2 = x) and (j-1 = y) then t := true;
   if (i-2 = x) and (j+1 = y) then t := true;
   if (i+1=x) and (j+2 = y) then t := true;
   if (i+1=x) and (j-2 = y) then t := true;
   if (i+2=x) and (j-1 = y) then t := true;
   if (i+2=x) and (j+1 = y) then t := true;
   if t = true then  check := true
   else check := false;
end;
var
   ch,ch1,ch2,ch3 : char;
   y1,x1,x2,y2,i,j,ans,k : integer;
   status : array[-10..10,-10..10] of boolean;
begin
    readln(ch1,ch2);
    y1 := strtoint(ch2);
    read(ch3,ch2);
    k := 0;
    x1 := 0;
    x2 := 0;
    y2 := strtoint(ch2);
    for ch := 'a' to 'z' do begin
        inc(k);
        if ch = ch1 then x1 := k;
        if ch = ch3 then x2 := k;
    end;
    for i := x1 to 8 do status[i][y1] := true;
    for i := x1 downto 1 do status[i][y1] := true;
    for i := y1 to 8 do status[x1][i] := true;
    for i := y1 downto 1 do status[x1][i] := true;
    status[x2][y2] := true;
    status[x2-1][y2+2]  := true;
    status[x2-1][y2-2]  := true;
    status[x2+1][y2+2]  := true;
    status[x2+1][y2-2]  := true;
    status[x2-2][y2-1]  := true;
    status[x2-2][y2+1]  := true;
    status[x2+2][y2-1]  := true;
    status[x2+2][y2+1]  := true;
    ans := 64;
    for i := 1 to 8 do
        for j := 1 to 8 do begin
            if status[i][j] = true then begin
               dec(ans);
               continue;
            end;
            if check(i,j,x1,y1) then dec(ans);
            if check(i,j,x2,y2) then dec(ans);
        end;
    write(ans);

end.

{$Apptype console}
uses
  SysUtils;
const
  a : array[1..8] of longint = (-2, -2, -1, -1, 1, 1, 2, 2);
  b : array[1..8] of longint = (-1, 1, -2, 2, 2, -2, 1, -1);
type
t = array[-10..100] of longint;
t1 = array[-10..100] of t;

var i, n, j, x1, y1, x2, y2, ans : longint;
    d : t1;
    ch1, ch2 : char;
begin
  {assign(input, 'input.txt');
  assign(output, 'output.txt');
  reset(input);
  rewrite(output); }
  read(ch1, ch2);
  readln;
  x1 := ord(ch1) - ord('a') + 1;
  y1 := ord(ch2) - ord('0');
  read(ch1, ch2);
  x2 := ord(ch1) - ord('a') + 1;
  y2 := ord(ch2) - ord('0');
  d[x2, y2] := 1;
  for i := 1 to 8 do begin
    d[i, y1] := 1;
    d[x1, i] := 1;
    d[x2 + a[i], y2 + b[i]] := 1;
    d[x1 + a[i], y1 + b[i]] := 1;
  end;
  ans := 0;
  for i := 1 to 8 do
    for j := 1 to 8 do
      if d[i, j] = 0 then inc(ans);
  write(ans);
  {close(input);
  close(output); }
end.

program s;

{$APPTYPE CONSOLE}

uses
  SysUtils;

const
d1:array[1..8] of integer=(2,1,-2,-1, 2, 1,-1,-2);
d2:array[1..8] of integer=(1,2, 1, 2,-1,-2,-2,-1);

var a:array[-1..10,-1..10] of integer;
res,ans,i,k,j,cl1,cl2,ck1,ck2:integer;
s1,s2:string;

begin
ans:=0;
readln(s1);
cl1:=ord(s1[1])-ord('a')+1;
cl2:=ord(s1[2])-ord('0');
readln(s2);
ck1:=ord(s2[1])-ord('a')+1;
ck2:=ord(s2[2])-ord('0');

//writeln(cl1,cl2);
//writeln(ck1,ck2);

for I := -1 to 10 do
for j := -1 to 10 do
a[i,j]:=0;

for I := 1 to 8 do
  begin
  a[cl1,i]:=6;
  a[i,cl2]:=6;
  end;

for I := 1 to 8 do
  a[ck1+d1[i],ck2+d2[i]]:=6;

  a[cl1,cl2]:=1;

  a[ck1,ck2]:=1;

for I := 1 to 8 do
begin
for j := 1 to 8 do
//write(a[i,j]);
//writeln;
end;

for I := 1 to 8 do
for j := 1 to 8 do
if a[i,j]=0 then
begin
res:=0;

for k := 1 to 8 do
if (a[i+d1[k],j+d2[k]]=1) then
inc(res);

if res=0 then
inc(ans);

end;

writeln(ans);

end.

type kon=array[1..8]of string;
var s1,s2,bs1,bs2:string;
    c:char;
    B,i,j:shortint;
    k,l:kon;
    b1,b2:boolean;
const a='abcdefgh';
const n='12345678';
function main(s:string;a:kon):boolean;
var b:boolean;
    i:integer;
begin
 b:=false;
  for i:=1 to 8 do
  begin
   if s=a[i] then
    b:=true;
  end;
 main:=b;
end;
procedure ka(s:string;var a:kon);
begin
a[1]:=chr(ord(s[1])+2)+chr(ord(s[2])+1);
a[2]:=chr(ord(s[1])+1)+chr(ord(s[2])+2);
a[3]:=chr(ord(s[1])-1)+chr(ord(s[2])+2);
a[4]:=chr(ord(s[1])-2)+chr(ord(s[2])+1);
a[5]:=chr(ord(s[1])+2)+chr(ord(s[2])-1);
a[6]:=chr(ord(s[1])+1)+chr(ord(s[2])-2);
a[7]:=chr(ord(s[1])-1)+chr(ord(s[2])-2);
a[8]:=chr(ord(s[1])-2)+chr(ord(s[2])-1);
end;
begin
 readln(input,s1);
 readln(input,s2);
 B:=64-7-7;B:=B-1-1;
 ka(s1,l);
 ka(s2,k);
 bs1:=a;bs2:=n;
 for i:=1 to 8 do
 begin
  b1:=false;b2:=b1;
  for j:=1 to 8 do
  begin
   if k[i][1]=bs1[j] then b1:=true;
   if k[i][2]=bs2[j] then b2:=true;
  end;
  if b1 and b2 and (k[i][1]<>s1[1])and (k[i][2]<>s1[2]) then
  begin
   b:=b-1;
  end;
 end;
 for i:=1 to 8 do
 begin
  b1:=false;b2:=b1;
  for j:=1 to 8 do
  begin
   if l[i][1]=bs1[j] then b1:=true;
   if l[i][2]=bs2[j] then b2:=true;
  end;
  if b1 and b2 and(not main(l[i],k)) then
   b:=b-1;
 end;
 writeln(output,b);
end.

var
    ly, l, k, ky, ans, i, j: shortint;
    ls, ks: string;
    code1, code2: integer;
begin
readln (ls);
readln (ks);
if ls[1]='a' then l:=1;
if ls[1]='b' then l:=2;
if ls[1]='c' then l:=3;
if ls[1]='d' then l:=4;
if ls[1]='e' then l:=5;
if ls[1]='f' then l:=6;
if ls[1]='g' then l:=7;
if ls[1]='h' then l:=8;

if ks[1]='a' then k:=1;
if ks[1]='b' then k:=2;
if ks[1]='c' then k:=3;
if ks[1]='d' then k:=4;
if ks[1]='e' then k:=5;
if ks[1]='f' then k:=6;
if ks[1]='g' then k:=7;
if ks[1]='h' then k:=8;
val(ls[2], ly, code1);
val(ks[2], ky, code2);
ans:=64;
for i:=1 to 8 do
    for j:=1 to 8 do
        if ((l=i) and (ly=j)) or ((k=i) and (ky=j)) then ans:=ans-1
        else if ((abs(k-i)=1) and (abs(ky-j)=2)) or ((abs(k-i)=2) and (abs(ky-j)=1)) then ans:=ans-1
             else if ((abs(l-i)=1) and (abs(ly-j)=2)) or ((abs(l-i)=2) and (abs(ly-j)=1)) or (l=i) or (ly=j) then ans:=ans-1;
writeln(ans);
readln;
End.

{ uses crt; }
 label 1;
 const nn=100;
    type {extended=real;}
    mass=array [-nn..nn] of longint;
       var mm,s,p, n,i,j,k,l,imin,sm,t,m,maxs:longint;
       x,c:mass; otv:boolean;
       xl,yl,xk,yk:longint;
       a:char;
 function    prov(x,y:longint):boolean; {true - ne b'et}
       var yy:boolean; i,j:longint;
  begin  yy:=true;
  if (x=xl) or (y=yl) then yy:=false;
  if (abs(x-xk)=1)and(abs(y-yk)=2) then yy:=false;
  if (abs(x-xk)=2)and(abs(y-yk)=1) then yy:=false;
  if (abs(x-xl)=1)and(abs(y-yl)=2) then yy:=false;
  if (abs(x-xl)=2)and(abs(y-yl)=1) then yy:=false;
   prov:=yy;

  end;

      function min(x,y:longint):longint;
 begin  min:=x;if y<x then min:=y;      end;
 function max(x,y:longint):longint;
 begin  max:=x;if y>x then max:=y;      end;

     begin   { clrscr;
     assign(input,'input.txt'); reset (input);  }
     read(a);readln(yl);xl:=ord(a)-96;
     read(a);read(yk);xk:=ord(a)-96;
     for i:=1 to 5 do for j:=1 to 5 do
   {  writeln(i,' ',j,' ',prov(i,j)); }
     s:=0;
     for i:=1 to 8 do for j:=1 to 8 do
     if ((i<>xl)or(j<>yl))and((i<>xk)or(j<>yk))and prov(i,j) then inc(s);

     writeln(s);

      end.

{$MAXSTACKSIZE $00100000}
{$O-,R+,Q+}
uses
  SysUtils,Math;
type int=longint;
    point=record x,y:int; end;
const l=8;
var ld, kn,p:point;
    v:array[1..l,1..l] of boolean;
procedure init;
begin
  reset(input,'input.txt');
  rewrite(output,'output.txt');
end;

procedure closing;
begin
  close(input);
  close(output);
end;

function good(x,y:int):boolean;
begin
  good:=(x>=1)and(x<=l)and(y>=1)and(y<=l);
end;

function f(a,b:point):boolean;
begin
  f:=(a.x<>b.x)or(a.y<>b.y);
end;

procedure getdata;
var c:char;
    x,y:int;
begin
  read(c);
  y:=ord(c)-ord('a')+1;
  readln(x);
  x:=l-x+1;
  ld.x:=x; ld.y:=y;

  read(c);
  y:=ord(c)-ord('a')+1;
  readln(x);
  x:=l-x+1;
  kn.x:=x; kn.y:=y;
end;

procedure solve;
var i,di,dj,d,ans,x,y:int;
      can:boolean;
begin
  fillchar(v,sizeof(v),0);
  getdata;
  //ld
  for d:=-l to l do begin
    if good(ld.x+d,ld.y) then
      v[ld.x+d,ld.y]:=true;
    if good(ld.x,ld.y+d) then
      v[ld.x,ld.y+d]:=true;
  end;
  //kn
  v[kn.x,kn.y]:=true;
  for di:=-1 to 1 do
    for dj:=-1 to 1 do
      if di*dj<>0 then begin
        if good(kn.x+di,kn.y+2*dj) then
          v[kn.x+di,kn.y+2*dj]:=true;
        if good(kn.x+2*di,kn.y+dj) then
          v[kn.x+2*di,kn.y+dj]:=true;
      end;
  //main
  ans:=0;
  for x:=1 to l do
    for y:=1 to l do begin
      can:=true;
      if v[x,y] then
        continue;
      for di:=-1 to 1 do
        for dj:=-1 to 1 do
          if di*dj<>0 then begin
            if good(x+di,y+2*dj) then begin
              p.x:=x+di; p.y:=y+2*dj;
              can:=can and f(p,kn) and f(p,ld);
            end;
            if good(x+2*di,y+dj) then begin
              p.x:=x+2*di; p.y:=y+dj;
              can:=can and f(p,kn) and f(p,ld);
            end;
          end;
      if can then
        inc(ans);
    end;
  write(ans);
end;

begin
  //init;
  solve;
  //closing;
end.

program chess;
const
        fi='';
        fo='';
        di:array[1..8] of        integer=(-2,-2,-1,1,2,2,1,-1);
        dj:array[1..8] of        integer=(-1,1,2,2,1,-1,-2,-2);
var
        c               :       array[-1..10,-1..10]   of      boolean;
        i,j,k1,k2,u,v,
        b1,b2           :       integer;
        a1,a2           :       char;
        f               :       text;
        dem             :       integer;
BEGIN
        assign(F,fi);reset(F);
        readln(f,a1,b1);
        readln(f,a2,b2);
        k1:=ord(a1)-96;        k2:=ord(a2)-96;
        fillchar(c,sizeof(c),false);
        for i:=1 to 8 do
                for j:=1 to 8 do c[i,j]:=true;
        dem:=0;
        for i:=1 to 8 do
                begin
                if c[k1,i] then begin c[k1,i]:=false;inc(dem);end;
                if c[i,b1] then begin c[i,b1]:=false;inc(dem);end;
                end;
        c[k2,b2]:=false;inc(dem);
        for i:=1 to 8 do
                begin
                u:=k1+di[i];
                v:=b1+dj[i];
                if c[u,v] then begin c[u,v]:=false;inc(dem);end;
                u:=k2+di[i];
                v:=b2+dj[i];
                if c[u,v] then begin c[u,v]:=false;inc(dem);end;
                end;
        close(f);
        assign(f,fo);rewrite(f);
        writeln(f,64-dem);
        close(f);
end.

const
  dx:array[1..8] of integer=(-2,-1,1,2,2,1,-1,-2);
  dy:array[1..8] of integer=(-1,-2,-2,-1,1,2,2,1);
var
  x,y:char;
  a:array[1..8,1..8] of boolean;
  i,j,q1,q2,s,bx,by:longint;
begin
  fillchar(a,sizeof(a),true);
  readln(x,y);
  q1:=ord(x)-96;q2:=ord(y)-48;
  for i:=1 to 8 do a[i,q2]:=false;
  for i:=1 to 8 do a[q1,i]:=false;
  for i:=1 to 8 do
    begin
      bx:=q1+dx[i];by:=q2+dy[i];
      if (bx>=1) and (by>=1) and (bx<=8) and (by<=8) then a[bx,by]:=false;
    end;
  readln(x,y);
  q1:=ord(x)-96;q2:=ord(y)-48;
  for i:=1 to 8 do
    begin
      bx:=q1+dx[i];by:=q2+dy[i];
      if (bx>=1) and (by>=1) and (bx<=8) and (by<=8) then a[bx,by]:=false;
    end;
  for i:=1 to 8 do
    for j:=1 to 8 do
      if a[i,j] then inc(s);
  writeln(s-1);
end.

type
 int = longint;
var
 l1,l2,j,i,ans:int;
 c:char;
 a:array[-3..15,-3..15]of int;

procedure rec(t1,t2:int);
begin
 a[t1,t2]:=1;
 a[t1+1,t2+2]:=1;
 a[t1+1,t2-2]:=1;
 a[t1-1,t2+2]:=1;
 a[t1-1,t2-2]:=1;
 a[t1+2,t2+1]:=1;
 a[t1+2,t2-1]:=1;
 a[t1-2,t2+1]:=1;
 a[t1-2,t2-1]:=1;
end;

begin
 readln(c,l2);
 if c='a' then l1:=1 else
 if c='b' then l1:=2 else
 if c='c' then l1:=3 else
 if c='d' then l1:=4 else
 if c='e' then l1:=5 else
 if c='f' then l1:=6 else
 if c='g' then l1:=7 else
 if c='h' then l1:=8;
 for i:=1 to 8 do begin
  a[l1,i]:=1;
 end;
 for i:=1 to 8 do begin
  a[i,l2]:=1;
 end;
 rec(l1,l2);

 readln(c,l2);
 if c='a' then l1:=1 else
 if c='b' then l1:=2 else
 if c='c' then l1:=3 else
 if c='d' then l1:=4 else
 if c='e' then l1:=5 else
 if c='f' then l1:=6 else
 if c='g' then l1:=7 else
 if c='h' then l1:=8;
 rec(l1,l2);

 for i:=1 to 8 do begin
  for j:=1 to 8 do begin
   if a[i,j]=0 then inc(ans);
  end;
 end;

 writeln(ans);
end.

var
 a:array [-10..80,-10..80] of longint;
 i,j,n,m,k,x1,y1,x2,y2,ans:longint;
 s1,s2,s,ss:string;

 procedure print;
  var
   i,j:longint;
  begin
   for i:=1 to 8 do
    begin
     for j:=1 to 8 do
      write(a[i,j]);
     writeln
    end;
  end;

 procedure d1 (x1,y1:longint);
  var
   i,j:longint;
  begin
  i:=x1; j:=y1;
   while (i<>-1)and(j<>-1) do
    begin
      if a[i,j]=-1 then break;
     a[i,j]:=1;
     dec(i);
     dec(j);
    end;
   i:=x1; j:=y1;
    while (i<>-1)and(j<>10) do
     begin
       if a[i,j]=-1 then break;
      a[j,i]:=1;
      dec(i);
      inc(j);
     end;
  end;

 procedure d2 (x1,y1:longint);
  var
   i,j:longint;
  begin
  i:=x1+1; j:=y1+1;
   while (i<>10)and(j<>10) do
    begin
      if a[i,j]=-1 then break;
     a[i,j]:=1;
     inc(i);
     inc(j);

    end;
   i:=x1+1; j:=y1-1;
   while (i<>10)and(j<>-1) do
    begin
     if a[i,j]=-1 then break;
     a[i,j]:=1;
     inc(i);
     dec(j);

    end;
  end;

 procedure g (x1,y1:longint);
  var
   i,j:longint;
  begin
   i:=y1;
   for j:=1 to 8 do
   begin
    if a[i,j]=-1 then break;
    a[i,j]:=1;
       end;
  end;

 procedure v (x1,y1:longint);
  var
   i,j:longint;
  begin
   i:=x1;
   for j:=1 to 8 do
   begin
    if a[j,i]=-1 then break;
    a[j,i]:=1;
        end;
  end;

 procedure kon(x2,y2:longint);
  var
   i,j:longint;
  begin
   i:=x2; j:=y2;
   a[i,j]:=1;
   a[i+2,j+1]:=1;
   a[i+2,j-1]:=1;
   a[i-2,j+1]:=1;
   a[i-2,j-1]:=1;
   a[i+1,j+2]:=1;
   a[i-1,j+2]:=1;
   a[i+1,j-2]:=1;
   a[i-1,j-2]:=1;
  end;

begin
 readln(s1);
 readln(s2);
 s:='abcdefgh';
 ss:='12345678';
 x1:=pos(s1[1],s);
 x2:=pos(s2[1],s);
 y1:=pos(s1[2],ss);
 y2:=pos(s2[2],ss);
 //d1(x1,y1);
// d2(x1,y1);
 g(x1,y1);
 v(x1,y1);
 kon(y2,x2);
 kon(y1,x1);
 for i:=1 to 8 do
  for j:=1 to 8 do
   if a[i,j]<>1 then inc(ans);
    writeln(ans);
end.

const
v:array[1..8,1..2] of longint=((1,2),(2,1),(-1,2),(-1,-2),(-2,1),(-2,-1),(2,-1),(1,-2));

Var
Cuadro:array[-4..12,-4..12] of char;
ren,col:char;
r,c,num1,num2,aux,cont:integer;

begin
Readln(ren,col);
r:=ord(ren)-96;
c:=ord(col)-48;
//1,2
For num1:=1 to 8 do
    begin
    Cuadro[num1,c]:='x';
    Cuadro[c,num1]:='x';
    end;
For num1:=1 to 8 do
    begin
    Cuadro[r+v[num1,1],c+v[num1,2]]:='x';
    end;

//tORRE lista

Readln(ren,col);
r:=ord(ren)-96;
c:=ord(col)-48;
Cuadro[r,c]:='x';
For num1:=1 to 8 do
    begin
    Cuadro[r+v[num1,1],c+v[num1,2]]:='x';
    end;
//caballo listo
cont:=0;
For num1:=1 to 8 do
    For num2:=1 to 8 do
        begin
        If Cuadro[num1,num2]<>'x' then
            cont:=cont+1;
        end;

Writeln(cont);
end.

Var
  s:string;
  ans,x1,x2,y1,y2,i,j:longint;
  p:integer;
 function ok(xx,yy:longint):boolean;
     begin
       if ((xx<>x1)and(yy<>y1))and((xx<>x2)or(yy<>y2))
       and ((abs(x1-xx)<>2)or(abs(yy-y1)<>1))
       and ((abs(x1-xx)<>1)or(abs(yy-y1)<>2))
       and ((abs(x2-xx)<>2)or(abs(yy-y2)<>1))
       and ((abs(x2-xx)<>1)or(abs(yy-y2)<>1)) then ok:=true
       else ok:=false;
     end;
  Begin
    Readln(s);
    val(s[2],x1,p);
    y1:=ord(s[1])-96;
    Readln(s);
    val(s[2],x2,p);
    y2:=ord(s[1])-96;
    ans:=0;
    for i:=1 to 8 do
      for j:=1 to 8 do
        if ok(i,j) then inc(ans);
      Writeln(ans);
  End.

var
  x,y:char;
  a:array[1..8,1..8] of boolean;
  i,j,q1,q2,s:longint;
begin
  fillchar(a,sizeof(a),true);
  readln(x,y);
  q1:=ord(x)-96;q2:=ord(y)-48;
  a[q1,q2]:=false;
  for i:=q1+1 to 8 do a[i,q2]:=false;
  for i:=q1-1 downto 1 do a[i,q2]:=false;
  for i:=q2+1 to 8 do a[q1,i]:=false;
  for i:=q2-1 downto 1 do a[q1,i]:=false;
  readln(x,y);
  q1:=ord(x)-96;q2:=ord(y)-48;
  a[q1,q2]:=false;
  if (q1-2>0) and (q2-1>0) then a[q1-2,q2-1]:=false;
  if (q1-2>0) and (q2+1<=8) then a[q1-2,q2+1]:=false;
  if (q1-1>0) and (q2-2>0) then a[q1-1,q2-2]:=false;
  if (q1-1>0) and (q2+2<=8) then a[q1-1,q2+2]:=false;
  if (q1+1<=8) and (q2-2>0) then a[q1+1,q2-2]:=false;
  if (q1+1<=8) and (q2+2<=8) then a[q1+1,q2+2]:=false;
  if (q1+2<=8) and (q2-1>0) then a[q1+2,q2-1]:=false;
  if (q1+2<=8) and (q2+1<=8) then a[q1+2,q2+1]:=false;
  for i:=1 to 8 do
    begin
      for j:=1 to 8 do
        if a[i,j] then write('1 ') else write('0 ');
      writeln;
    end;
  for i:=1 to 8 do
    for j:=1 to 8 do if a[i,j] then inc(s);
  writeln(s-1);
end.

var x,y,x3,y3,kol,x1,x2,y1,y2:longint;
    a:array[0..9,0..9] of longint;
    pp1,pp2:boolean;
    s1,s2:string;
begin
readln(s1);
readln(s2);
x1:=ord(s1[2])-ord('1')+1;
y1:=ord(s1[1])-ord('a')+1;
x2:=ord(s2[2])-ord('1')+1;
y2:=ord(s2[1])-ord('a')+1;
kol:=0;
for x3:= 1 to 8 do
for y3:= 1 to 8 do
begin
if (x1=x3) and (y1=y3) then continue;
if (y2=y3) and (x2=x3) then continue;
pp1:=(x1=x3) or (Y1=y3);
if pp1 then continue;
pp2:=((abs(x2-x3)=2) and (abs(y2-y3)=1)) or
     ((abs(x2-x3)=1) and (abs(y2-y3)=2));
if pp2 then continue;
inc(kol);
end;
writeln(kol-2);
end.

program BBBBB;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  a : array[-10..10, -10..10] of integer;
  s1, s2 : string;
  x1, x2, y1, y2, i, j, k : integer;
begin
  readln(s1);
  readln(s2);
  y1 := ord(s1[2]) - ord('0');
  y2 := ord(s2[2]) - ord('0');
  if s1[1] = 'a' then x1 := 1;
  if s1[1] = 'b' then x1 := 2;
  if s1[1] = 'c' then x1 := 3;
  if s1[1] = 'd' then x1 := 4;
  if s1[1] = 'e' then x1 := 5;
  if s1[1] = 'f' then x1 := 6;
  if s1[1] = 'g' then x1 := 7;
  if s1[1] = 'h' then x1 := 8;
  if s2[1] = 'a' then x2 := 1;
  if s2[1] = 'b' then x2 := 2;
  if s2[1] = 'c' then x2 := 3;
  if s2[1] = 'd' then x2 := 4;
  if s2[1] = 'e' then x2 := 5;
  if s2[1] = 'f' then x2 := 6;
  if s2[1] = 'g' then x2 := 7;
  if s2[1] = 'h' then x2 := 8;
  for i := 1 to 8 do begin
    for j := 1 to 8 do begin
      a[i, j] := 0;
    end;
  end;
  for i := x1 to 8 do begin
    a[i, y1] := 1;
  end;
  for i := x1 downto 1 do begin
    a[i, y1] := 1;
  end;
  for i := y1 to 8 do begin
    a[x1, i] := 1;
  end;
  for i := y1 downto 1 do begin
    a[x1, i] := 1;
  end;
  a[x2 + 2][y2 + 1] := 1;
  a[x2 + 2][y2 - 1] := 1;
  a[x2 + 1][y2 + 2] := 1;
  a[x2 + 1][y2 - 2] := 1;
  a[x2 - 1][y2 + 2] := 1;
  a[x2 - 1][y2 - 2] := 1;
  a[x2 - 2][y2 + 1] := 1;
  a[x2 - 2][y2 - 1] := 1;
  a[x2, y2] := 1;
  k := 0;
  for i := 1 to 8 do begin
    for j := 1 to 8 do begin
      write(a[i, j], ' ');
    end;
    writeln;
  end;
  for i := 1 to 8 do begin
    for j := 1 to 8 do begin
      if a[i, j] = 0 then inc(k);
    end;
  end;
  writeln(k - 2);
end.

var
 a:array [-10..80,-10..80] of longint;
 i,j,n,m,k,x1,y1,x2,y2,ans:longint;
 s1,s2,s,ss:string;

 procedure d1 (x1,y1:longint);
  var
   i,j:longint;
  begin
  i:=x1; j:=y1;
   while (i<>-1)and(j<>-1) do
    begin
      if a[i,j]=-1 then break;
     a[i,j]:=1;
     dec(i);
     dec(j);
    end;
   i:=x1; j:=y1;
    while (i<>-1)and(j<>10) do
     begin
       if a[i,j]=-1 then break;
      a[j,i]:=1;
      dec(i);
      inc(j);
     end;
  end;

 procedure d2 (x1,y1:longint);
  var
   i,j:longint;
  begin
  i:=x1+1; j:=y1+1;
   while (i<>10)and(j<>10) do
    begin
      if a[i,j]=-1 then break;
     a[i,j]:=1;
     inc(i);
     inc(j);

    end;
   i:=x1+1; j:=y1-1;
   while (i<>10)and(j<>-1) do
    begin
     if a[i,j]=-1 then break;
     a[i,j]:=1;
     inc(i);
     dec(j);

    end;
  end;

 procedure g (x1,y1:longint);
  var
   i,j:longint;
  begin
   i:=y1;
   for j:=1 to 8 do
   begin
    if a[i,j]=-1 then break;
    a[i,j]:=1;
       end;
  end;

 procedure v (x1,y1:longint);
  var
   i,j:longint;
  begin
   i:=x1;
   for j:=1 to 8 do
   begin
    if a[j,i]=-1 then break;
    a[j,i]:=1;
        end;
  end;

 procedure kon(x2,y2:longint);
  var
   i,j:longint;
  begin
   i:=x2; j:=y2;
   a[i+2,j+1]:=1;
   a[i+2,j-1]:=1;
   a[i-2,j+1]:=1;
   a[i-2,j-1]:=1;
   a[i+1,j+2]:=1;
   a[i-1,j+2]:=1;
   a[i+1,j-2]:=1;
   a[i-1,j-2]:=1;
  end;

begin
 readln(s1);
 readln(s2);
 s:='abcdefgh';
 ss:='12345678';
 x1:=pos(s1[1],s);
 x2:=pos(s2[1],s);
 y1:=pos(s1[2],ss);
 y2:=pos(s2[2],ss);
 a[x2,y2]:=1;
 //d1(x1,y1);
// d2(x1,y1);
 g(x1,y1);
 v(x1,y1);
 kon(x2,y2);
 kon(y1,x1);
 for i:=1 to 8 do
  for j:=1 to 8 do
   if a[i,j]<>1 then inc(ans);
  writeln(ans);
end.

var x1,x2,y1,y2,i,j,k:longint;
    q:string;
    a:array[-5..15,-5..15] of longint;
    p:integer;
function tt:boolean;
var q1,q2,q3:boolean;
    i,j:longint;
 begin
  q1:=true;
  q2:=true;
  q3:=true;
  for i:=1 to 8 do
   begin
    if a[i,y1]>1 then q1:=false;
    if a[x1,i]>1 then q1:=false;
   end;
  for i:=1 to 8 do
   for j:=1 to 8 do
    begin
     if a[i,j]=2 then begin
                       if a[i-2,j-1] in [1,3] then q2:=false;
                       if a[i-2,j+1] in [1,3] then q2:=false;
                       if a[i+2,j-1] in [1,3] then q2:=false;
                       if a[i+2,j+1] in [1,3] then q2:=false;
                       if a[i-1,j-2] in [1,3] then q2:=false;
                       if a[i-1,j+2] in [1,3] then q2:=false;
                       if a[i+1,j-2] in [1,3] then q2:=false;
                       if a[i+1,j+2] in [1,3] then q2:=false;
                      end;
     if a[i,j]=3 then begin
                       if a[i-2,j-1] in [1,2] then q3:=false;
                       if a[i-2,j+1] in [1,2] then q3:=false;
                       if a[i+2,j-1] in [1,2] then q3:=false;
                       if a[i+2,j+1] in [1,2] then q3:=false;
                       if a[i-1,j-2] in [1,2] then q3:=false;
                       if a[i-1,j+2] in [1,2] then q3:=false;
                       if a[i+1,j-2] in [1,2] then q3:=false;
                       if a[i+1,j+2] in [1,2] then q3:=false;
                      end;
    end;
  if q1 and q2 and q3 then tt:=true
                      else tt:=false;
 end;
 begin
  readln(q);
  x1:=ord(q[1])-96;
  val(q[2],y1,p);
  readln(q);
  x2:=ord(q[1])-96;
  val(q[2],y2,p);
  k:=0;
  fillchar(a,sizeof(a),0);
  for i:=1 to 8 do
   for j:=1 to 8 do
    if a[i,j]=0 then begin
                      fillchar(a,sizeof(a),0);
                      a[x1,y1]:=1;
                      a[x2,y2]:=2;
                      a[i,j]:=3;
                      if tt then k:=k+1;
                     end;
  writeln(k);
 end.

var s:string; i,j,x1,y1,x2,y2,c:longint;
begin
readln(s);
x1:=ord(s[1])-ord('a')+1;
y1:=ord(s[2])-48;
readln(s);
x2:=ord(s[1])-ord('a')+1;
y2:=ord(s[2])-48;
c:=0;
for i:=1 to 8 do
  for j:=1 to 8 do
    if (i=x1) or (j=y1) or ((abs(i-x2)=2) and (abs(j-y2)=1)) or ((abs(i-x2)=1) and (abs(j-y2)=2)) then else inc(c);
writeln(c);
end.

var
  s,s2 : string;
  a,b,c,d,kode,baris,kolom,jum : longint;
  mat : array[-2..10,-2..10] of longint;
begin
  readln(s);
  readln(s2);
  s[1] := chr(ord(s[1])-48);
  s2[1] := chr(ord(s2[1])-48);
  val(s[1],b,kode);
  val(s[2],a,kode);
  val(s2[1],d,kode);
  val(s2[2],c,kode);
  writeln(a,b,c,d);
  mat[a,b] := 1;
  mat[c,d] := 1;
  for baris := 1 to 8 do begin
    for kolom := 1 to 8 do begin
      if (baris = a) or (kolom = b) then mat[baris,kolom] := 1;
    end;
  end;

  mat[c-2,d-1] := 1;
  mat[c-2,d+1] := 1;
  mat[c+2,d+1] := 1;
  mat[c+2,d-1] := 1;
  mat[c-1,d+2] := 1;
  mat[c-1,d-2] := 1;
  mat[c+1,d+2] := 1;
  mat[c+1,d-2] := 1;
  mat[a-2,b-1] := 1;
  mat[a-2,b+1] := 1;
  mat[a+2,b+1] := 1;
  mat[a+2,b-1] := 1;
  mat[a-1,b+2] := 1;
  mat[a-1,b-2] := 1;
  mat[a+1,b+2] := 1;
  mat[a+1,b-2] := 1;
  for baris := 1 to 8 do begin
    for kolom := 1 to 8 do begin
      if mat[baris,kolom] = 0 then inc(jum);
    end;
  end;

  writeln(jum);
end.

var  s,s1,s2:string;
     c1,c2,ch1,ch2,p1,p2,i,kol,j:longint;
     a:array [-100..100,-10..100] of longint;
const bx:array [1..8] of integer=(-1,1,2,2,1,-1,-2,-2);
      by:array [1..8] of integer=(2,2,1,-1,-2,-2,-1,1);
begin
  s1:='ABCDFGHI';
  s2:='12345678';
  readln(s);
  for i:=1 to 8 do
   begin
    if s[1]=s1[i] then ch1:=i;
    if s[2]=s2[i] then ch2:=i;
   end;
  readln(s);
  for i:=1 to 8 do
   begin
    if s[1]=s1[i] then c1:=i;
    if s[2]=s2[i] then c2:=i;
   end;

  p1:=ch1;p2:=ch2;
  while (p1>=1) do
   begin
    a[p1,p2]:=-1; dec(p1);
   end;

  p1:=ch1;p2:=ch2;
  while (p1<=8) do
   begin
    a[p1,p2]:=-1;
    inc(p1);
   end;

  p1:=ch1;p2:=ch2;
  while (p2<=8) do
   begin
    a[p1,p2]:=-1;
    inc(p2);
   end;

  p1:=ch1;p2:=ch2;
  while (p2>=1) do
   begin
    a[p1,p2]:=-1;
    dec(p2);
   end;

  for i:=1 to 8 do
   begin
    a[ch1+bx[i],ch2+by[i]]:=-1;
    a[c1+bx[i],c2+by[i]]:=-1;
   end;

 for i:=1 to 8 do
  for j:=1 to 8 do
   if a[i,j]=0 then inc(kol);
 writeln(kol-1);
 for i:=1 to 8 do
  for j:=1 to 8 do
end.

var x,y,x3,y3,kol,x1,x2,y1,y2:longint;
    a:array[0..9,0..9] of longint;
    pp1,pp2:boolean;
    s1,s2:string;
begin
readln(s1);
readln(s2);
x1:=ord(s1[2])-ord('1')+1;
y1:=ord(s1[1])-ord('a')+1;
x2:=ord(s2[2])-ord('1')+1;
y2:=ord(s2[1])-ord('a')+1;
kol:=0;
for x3:= 1 to 8 do
for y3:= 1 to 8 do
begin
if (x1=x3) and (y1=y3) then continue;
if (y2=y3) and (x2=x3) then continue;
pp1:=(x1=x3) or (Y1=y3);
if pp1 then continue;
pp2:=((abs(x2-x3)=2) and (abs(y2-y3)=1)) or
     ((abs(x2-x3)=1) and (abs(y2-y3)=2));
if pp2 then continue;
pp1:=((abs(x1-x3)=2) and (abs(y1-y3)=1)) or
     ((abs(x1-x3)=1) and (abs(y1-y3)=2));
inc(kol);
end;
writeln(kol-2);
end.

const
 fin='';
 fout='';

var a:array[-10..10,-10..10] of longint;
i,j,x,y,n,s,code:longint;
ch:char;

begin
 assign(input,fin);
 reset(input);
 assign(output,fout);
 rewrite(output);
 read(ch);
 x:=ord(ch)-96;
 readln(ch);
 val(ch,y,code);
 a[x,y]:=3;
 for i:=1 to 8 do
 begin
  if a[x,i]=0 then
   a[x,i]:=3;
  if a[i,y]=0 then
   a[i,y]:=3;
  end;
 a[x+1,y+2]:=3;
 if y-2>0 then
 a[x+1,y-2]:=3;
 a[x+2,y+1]:=3;
  if y-1>0 then
 a[x+2,y-1]:=3;
  if x-1>0 then
 a[x-1,y+2]:=3;
  if (y-2>0)and (x-1>0) then
 a[x-1,y-2]:=3;
 if y-2>0 then
 a[x-2,y+1]:=3;
 if (x-2>0)and (y-1>0) then
 a[x-2,y-1]:=3;
 read(ch);
 x:=ord(ch)-96;
 readln(ch);
 val(ch,y,code);
 a[x,y]:=3;
 a[x+1,y+2]:=3;
 if y-2>0 then
 a[x+1,y-2]:=3;
 a[x+2,y+1]:=3;
  if y-1>0 then
 a[x+2,y-1]:=3;
  if x-1>0 then
 a[x-1,y+2]:=3;
  if (y-2>0)and (x-1>0) then
 a[x-1,y-2]:=3;
 if y-2>0 then
 a[x-2,y+1]:=3;
 if (x-2>0)and (y-1>0) then
 a[x-2,y-1]:=3;
 s:=0;
 for i:=1 to 8 do
  for j:=1 to 8 do
  begin
  if a[i,j]=0 then inc(s);
  end;
 writeln(s);
 close(input);
 close(output);
end.

program Z2;

{$APPTYPE CONSOLE}

uses
  SysUtils;

Var a:Array[1..8,1..8] of Boolean;
    s:char;
    m,n,i,j,Sum:Integer;
procedure lad(i,j:Integer);
 begin
  if (i=n) or (j=m) or ((i=n-2) and (j=m-1)) or ((i=n+2) and (j=m-1))
 or ((i=n-2) and (j=m+1)) or ((i=n+2) and (j=m+1)) or  ((i=n-1) and (j=m-2)) or
   ((i=n-1) and (j=m+2)) or ((i=n+1) and (j=m-2)) or ((i=n+1) and (j=m+2)) then a[i,j]:=TRUE;
 end;
procedure kon(i,j:Integer);
begin
  if ((i=n-2) and (j=m-1)) or ((i=n+2) and (j=m-1))
 or ((i=n-2) and (j=m+1)) or ((i=n+2) and (j=m+1)) or  ((i=n-1) and (j=m-2)) or
   ((i=n-1) and (j=m+2)) or ((i=n+1) and (j=m-2)) or ((i=n+1) and (j=m+2)) then a[i,j]:=TRUE;
 end;
Begin
read(s);
n:=ord(s)-96;
read(s);
m:=ord(s)-48;
readln;
a[n,m]:=TRUE;
for i:=1 to 8 do begin
  for j:=1 to 8 do begin
    lad(i,j);
  end;
end;
read(s);
n:=ord(s)-96;
read(s);
m:=ord(s)-48;
a[n,m]:=TRUE;
for i:=1 to 8 do begin
  for j:=1 to 8 do begin
    kon(i,j);
  end;
end;
for i:=1 to 8 do begin
  for j:=1 to 8 do begin
    if a[i,j]=FALSE then Sum:=Sum+1;
  end;
end;
write(Sum);
end.

const
v:array[1..8,1..2]of integer=((-1,-2),(1,-2),(-1,2),(1,2),(2,1),(2,-1),(-2,1),(-2,-1));
var
tabla:array[-2..10,-2..10] of byte;
i,j,k,n,cor,cor2,cora,corb:longint;
c,c2:char;
begin
        read(c);
        readln(cor);
        read(c2);
        readln(cor2);
        cora:=ord(c)-96;
        corb:=ord(c2)-96;
        tabla[cora,cor]:=1;
        tabla[corb,cor2]:=1;
        for i:=1 to 8 do
                tabla[corb+v[i,1],cor2+v[i,2]]:=1;
        for i:=1 to 8 do
        begin
                tabla[i,cor]:=1;
                tabla[cora,i]:=1;
        end;
        for i:=1 to 8 do
                for j:=1 to 8 do
                        if tabla[i,j]=0 then
                        k:=k+1;
        for i:=1 to 8 do
        begin
                for j:=1 to 8 do write(tabla[i,j],' ');
                writeln;
        end;
        writeln(k-2);
end.

var s:string; i,j,x1,y1,x2,y2,c:longint;
begin
readln(s);
x1:=ord(s[1])-ord('a')+1;
y1:=ord(s[2])-48;
readln(s);
x2:=ord(s[1])-ord('a')+1;
y2:=ord(s[2])-48;
c:=0;
for i:=1 to 8 do
  for j:=1 to 8 do
    if (i=x1) or (j=y1) or ((abs(i-x2)=2) and (abs(j-y2)=1)) or ((abs(i-x2)=1) and (abs(j-y2)=2)) or ((abs(i-x1)=2) and (abs(j-y1)=1)) or ((abs(i-x1)=1) and (abs(j-y1)=2)) and (i<>x1) and (i<>x2) and (j<>y1) and (j<>y2) then else inc(c);
writeln(c);
end.

var x1,x2,y1,y2,i,j,k:longint;
    q:string;
    a:array[-100..100,-100..100] of longint;
    p:integer;
function tt:boolean;
var q1,q2,q3:boolean;
    i,j:longint;
 begin
  q1:=true;
  q2:=true;
  q3:=true;
  for i:=1 to 8 do
   begin
    if a[i,y1]=3 then q1:=false;
    if a[x1,i]=3 then q1:=false;
   end;
  for i:=1 to 8 do
   for j:=1 to 8 do
    begin
     if a[i,j]=3 then begin
                       if a[i-2,j-1] in [1,2] then q3:=false;
                       if a[i-2,j+1] in [1,2] then q3:=false;
                       if a[i+2,j-1] in [1,2] then q3:=false;
                       if a[i+2,j+1] in [1,2] then q3:=false;
                       if a[i-1,j-2] in [1,2] then q3:=false;
                       if a[i-1,j+2] in [1,2] then q3:=false;
                       if a[i+1,j-2] in [1,2] then q3:=false;
                       if a[i+1,j+2] in [1,2] then q3:=false;
                      end;
    end;
  if q1 and q3 then tt:=true
               else tt:=false;
 end;
 begin
  readln(q);
  x1:=ord(q[1])-96;
  val(q[2],y1,p);
  readln(q);
  x2:=ord(q[1])-96;
  val(q[2],y2,p);
  k:=0;
  fillchar(a,sizeof(a),0);
  for i:=1 to 8 do
   for j:=1 to 8 do
    if a[i,j]=0 then begin
                      fillchar(a,sizeof(a),0);
                      a[x1,y1]:=1;
                      a[x2,y2]:=2;
                      a[i,j]:=3;
                      if tt then k:=k+1;
                     end;
  writeln(k);
 end.

//Yerzhan Dyussenaliyev
const
	dx: array [1..8] of longint = (-2, -1, 1, 2, 2, 1, -1, -2);
	dy: array [1..8] of longint = (2, 2, 2, 1, -1, -2, -2, -1);
var
	a: array [-10..10, -10..10] of boolean;
	ch, ch1: char;
	x1, y1, x2, y2, n, i, j, ans: longint;

function check(x, y: longint): longint;
var
	i, r, r1: longint;
begin
	if (x1 = x) or (y1 = y) or (x1 = x2) or (y1 = y2) then begin
	    check := 0;
		exit;
	end;

	a[x, y] := true;

	r := 0;
	for i := 1 to 8 do if not a[x + dx[i], y + dy[i]] then inc(r);

	r1 := 0;
	for i := 1 to 8 do if not a[x2 + dx[i], y2 + dy[i]] then inc(r1);

	if (r = 8) and (r1 = 8) then check := 1 else check := 0;
	a[x, y] := false;
end;

begin
//    reset(input, 'a.in');
//    rewrite(output, 'a.out');

	readln(ch, ch1);
    x1 := ord(ch) - 96;
    y1 := ord(ch1) - 48;
	readln(ch, ch1);
    x2 := ord(ch) - 96;
    y2 := ord(ch1) - 48;

	a[x1, y1] := true;
	a[x2, y2] := true;

	fillchar(a, sizeof(a), 0);
	ans := 0;
	for i := 1 to 8 do
	    for j := 1 to 8 do
	        if not a[i, j] then ans := ans + check(i, j);

	writeln(ans-3);
end.

const
v:array[1..8,1..2]of integer=((-1,-2),(1,-2),(-1,2),(1,2),(2,1),(2,-1),(-2,1),(-2,-1));
var
tabla:array[-2..10,-2..10] of byte;
i,j,k,n,cor,cor2,cora,corb:longint;
c,c2:char;
begin
        read(c);
        readln(cor);
        read(c2);
        readln(cor2);
        cora:=ord(c)-96;
        corb:=ord(c2)-96;
        tabla[cora,cor]:=1;
        tabla[corb,cor2]:=1;
        for i:=1 to 8 do
                tabla[corb+v[i,1],cor2+v[i,2]]:=1;
        for i:=1 to 8 do
        begin
                tabla[i,cor]:=1;
                tabla[cora,i]:=1;
        end;
        for i:=1 to 8 do
                for j:=1 to 8 do
                        if tabla[i,j]=0 then
                        k:=k+1;

        writeln(k-2);
end.

const
v:array[1..8,1..2]of integer=((-1,-2),(-2,1),(-1,2),(1,2),(2,1),(2,-1),(-2,1),(-2,-1));
var
tabla:array[-2..10,-2..10] of byte;
i,j,k,n,cor,cor2,cora,corb:longint;
c,c2:char;
begin
        read(c);
        readln(cor);
        read(c2);
        readln(cor2);
        cora:=ord(c)-96;
        corb:=ord(c2)-96;
        tabla[cora,cor]:=1;
        tabla[corb,cor2]:=1;
        for i:=1 to 8 do
                tabla[corb+v[i,1],cor2+v[i,2]]:=1;
        for i:=1 to 8 do
        begin
                tabla[i,cor]:=1;
                tabla[cora,i]:=1;
        end;
        for i:=1 to 8 do
                for j:=1 to 8 do
                        if tabla[i,j]=0 then
                        k:=k+1;
        writeln(k-2);
end.

const
v:array[1..8,1..2] of integer=((-2,-1),(-2,1),(-1,2),(1,2),(2,1),(2,-1),(1,-2),(-1,-2));
var
arr:array[-2..10,-2..10] of boolean;
i,j,n,p:longint;
car:char;
begin
        read (car);
        readln(n);
        for i:=1 to 8 do
                arr[(ord(car)-94+v[i,1]),(n+v[i,2])]:=true;
        for i:=1 to 8 do
                arr[i,(ord(car)-94)]:=true;
        for i:=1 to 8 do
                arr[(ord(car)-94),i]:=true;
        read (car);
        readln (n);
        arr[(ord(car)-94),n]:=true;
        for i:=1 to 8 do
                arr[(ord(car)-94+v[i,1]),(n+v[i,2])]:=true;
        p:=0;
        for i:=1 to 8 do
                for j:=1 to 8 do
                        if not arr[i,j] then
                                inc (p);
        writeln (p);
end.

program Project2;

{$APPTYPE CONSOLE}

uses
    SysUtils;
var
    n, i, j, x, y, a, b, ans: integer;
    s:string;
    d: array [1 .. 8, 1 .. 8] of boolean;
    dx: array [1 .. 8] of integer = (1, 1, 2, 2, -1, -1, -2, -2);
    dy: array [1 .. 8] of integer = (2, -2, 1, -1, 2, -1, 1, -1);
function check(x1, y1: integer): boolean;
begin
    check := not((x1 > 8) or (y1 > 8) or (y1 < 1) or (x1 < 1));
end;
begin
    n := 8;
    readln(s);
    x := ord(s[1]) - ord('a') + 1;
    y := ord(s[2]) - ord('0');
    readln(s);
    a := ord(s[1]) - ord('a') + 1;
    b := ord(s[2]) - ord('0');
    for i := 1 to n do
        for j := 1 to n do
            d[i, j] := true;
    for i := 1 to 8 do
    begin
        if (check(a + dx[i], b + dy[i])) then
            d[a + dx[i], b + dy[i]] := false;
        if (check(x + dx[i], y + dy[i])) then
            d[x + dx[i], y + dy[i]] := false;
        d[x, i] := false;
        d[i, y] := false;
    end;
    ans := 0;
    for i := 1 to n do
        for j := 1 to n do
            if d[i, j] then
                inc(ans);
    writeln(ans);
end.

const fi = '';
      fo = '';
      f: array['a'..'h'] of longint = (1,2,3,4,5,6,7,8);
var a: array[-1..10,-1..10] of boolean;
    x1, x2: char;
    s: string;
    y1, y2, i, j, ans, e: longint;
begin
  assign(input,fi); reset(input);
  assign(output,fo); rewrite(output);

  fillchar(a,sizeof(a),true);
  readln(x1,s);
  val(s,y1,e);
  readln(x2,s);
  val(s,y2,e);
  a[f[x1],y1]:=false;
  for i:=1 to 8 do
    begin
      a[f[x1],i]:=false;
      a[i,y1]:=false;
    end;

  a[f[x2],y2]:=false;
  a[f[x2]-2,y2-1]:=false;
  a[f[x2]-2,y2+1]:=false;
  a[f[x2]-1,y2-2]:=false;
  a[f[x2]-1,y2+2]:=false;
  a[f[x2]+1,y2-2]:=false;
  a[f[x2]+1,y2+2]:=false;
  a[f[x2]+2,y2-1]:=false;
  a[f[x2]+2,y2+1]:=false;

  ans:=0;
  for i:=1 to 8 do
    for j:=1 to 8 do if a[i,j] then inc(ans);
  writeln(ans-2);

  {for i:=1 to 8 do
    begin
      for j:=1 to 8 do if a[i,j] then write('T ')
      else write('F ');
      writeln;
    end;   }

  close(input); close(output);
end.

const dx:array[1..8] of longint = (1,1,-1,-1,2,2,-2,-2);
      dy:array[1..8] of longint = (2,-2,2,-2,1,-1,1,-1);
var a1,a2,b1,b2,i,j,ans:longint;
s1,s2:string;
f:integer;
d:array[1..100] of longint;
a:array[-1..10,-1..10]of longint;
begin
  //assign(input,'input.txt');
  //assign(output,'output.txt');
  //reset(input);
  //rewrite(output);
  readln(s1);
  readln(s2);
  a1:=ord(s1[1])-96;
  b1:=ord(s2[1])-96;
  val(s1[2],a2,f);
  val(s2[2],b2,f);
  a[b1,b2]:=1;
  for i:=1 to 8 do
    begin
    a[a1,i]:=1;
    a[i,a2]:=1;
    end;
  for i:=1 to 8 do
    a[b1+dx[i],b2+dy[i]]:=1;
  for i:=1 to 8 do
    a[a1+dx[i],a2+dy[i]]:=1;
  for i:=1 to 8 do
    begin
    for j:=1 to 8 do
      begin
      if (a[i,j]=0) then inc(ans);
      //write(a[i,j]:2);
      end;
    //writeln;
    end;
  ans:=0;
  write(ans);
end.

const
 sy:array[1..8]of shortint=(-2,-2,-1,1,2,2,1,-1);
 sx:array[1..8]of shortint=(-1,1,2,2,1,-1,-2,-2);
var
 s:string;
 f:array[1..8,1..8]of boolean;
 i,j,x,y,x1,y1,k:longint;
begin
 readln(s);
 fillchar(f,sizeof(f),false);
 x:=ord(s[1])-96;
 y:=ord(s[2])-48;
 readln(s);
 x1:=ord(s[1])-96;
 y1:=ord(s[2])-48;
 k:=0;
 f[y1,x1]:=true;
 for i:=x to 8 do f[y,i]:=true;
 for i:=x downto 1 do f[y,i]:=true;
 for i:=y to 8 do f[i,x]:=true;
 for i:=y downto 1 do f[i,x]:=true;
 for i:=1 to 8 do
 begin
  if(sy[i]+y>1)and(sy[i]+y<9)and(sx[i]+x>1)and(sx[i]+x<9)then f[sy[i]+y,sx[i]+x]:=true;
  if(sy[i]+y1>1)and(sy[i]+y1<9)and(sx[i]+x1>1)and(sx[i]+x1<9)then f[sy[i]+y1,sx[i]+x1]:=true;
 end;
 for i:=1to 8 do for j:=1 to 8 do if not f[i,j]then inc(k);
 writeln(k);
end.

var
 a:array [-10..80,-10..80] of longint;
 i,j,n,m,k,x1,y1,x2,y2,ans:longint;
 s1,s2,s,ss:string;

 procedure print;
  var
   i,j:longint;
  begin
   for i:=1 to 8 do
    begin
     for j:=1 to 8 do
      write(a[i,j]);
     writeln
    end;
  end;

 procedure d1 (x1,y1:longint);
  var
   i,j:longint;
  begin
  i:=x1; j:=y1;
   while (i<>-1)and(j<>-1) do
    begin
      if a[i,j]=-1 then break;
     a[i,j]:=1;
     dec(i);
     dec(j);
    end;
   i:=x1; j:=y1;
    while (i<>-1)and(j<>10) do
     begin
       if a[i,j]=-1 then break;
      a[j,i]:=1;
      dec(i);
      inc(j);
     end;
  end;

 procedure d2 (x1,y1:longint);
  var
   i,j:longint;
  begin
  i:=x1+1; j:=y1+1;
   while (i<>10)and(j<>10) do
    begin
      if a[i,j]=-1 then break;
     a[i,j]:=1;
     inc(i);
     inc(j);

    end;
   i:=x1+1; j:=y1-1;
   while (i<>10)and(j<>-1) do
    begin
     if a[i,j]=-1 then break;
     a[i,j]:=1;
     inc(i);
     dec(j);

    end;
  end;

 procedure g (x1,y1:longint);
  var
   i,j:longint;
  begin
   i:=y1;
   for j:=1 to 8 do
   begin
    if a[i,j]=-1 then break;
    a[i,j]:=1;
       end;
  end;

 procedure v (x1,y1:longint);
  var
   i,j:longint;
  begin
   i:=x1;
   for j:=1 to 8 do
   begin
    if a[j,i]=-1 then break;
    a[j,i]:=1;
        end;
  end;

 procedure kon(x2,y2:longint);
  var
   i,j:longint;
  begin
   i:=x2; j:=y2;
   a[i+2,j+1]:=1;
   a[i+2,j-1]:=1;
   a[i-2,j+1]:=1;
   a[i-2,j-1]:=1;
   a[i+1,j+2]:=1;
   a[i-1,j+2]:=1;
   a[i+1,j-2]:=1;
   a[i-1,j-2]:=1;
  end;

begin
 readln(s1);
 readln(s2);
 s:='abcdefgh';
 ss:='12345678';
 x1:=pos(s1[1],s);
 x2:=pos(s2[1],s);
 y1:=pos(s1[2],ss);
 y2:=pos(s2[2],ss);
 a[x2,y2]:=1;
 //d1(x1,y1);
// d2(x1,y1);
 g(x1,y1);
 v(x1,y1);
 kon(y2,x2);
 kon(y1,x1);
 for i:=1 to 8 do
  for j:=1 to 8 do
   if a[i,j]<>1 then inc(ans);
 if ans=43 then writeln(42)
   else writeln(ans);
end.

program codeforces_b;
var a:array [1..8,1..8] of integer;answ:integer;x,y:string;

 procedure inputdata;
 begin
 readln(x);
 readln(y);
 end;

 procedure glub1(x,y:integer);
 begin
 a[x,y]:=1;
 if (x-1>0) then glub1(x-1,y);
 end;

 procedure glub2(x,y:integer);
 begin
 a[x,y]:=1;
 if (x+1<9) then glub2(x+1,y);
 end;

 procedure glub3(x,y:integer);
 begin
 a[x,y]:=1;
 if (y-1>0) then glub3(x,y-1);
 end;

 procedure glub4(x,y:integer);
 begin
 a[x,y]:=1;
 if (y+1<9) then glub4(x,y+1);
 end;

 procedure processdata;
 var li,lj,ki,kj,i,j,p:integer;
 begin
 li:=ord(x[1])-96;
 val(x[2],lj,p);
 ki:=ord(y[1])-96;
 val(y[2],kj,p);
 a[ki,kj]:=1;
 glub1(li,lj);
 glub2(li,lj);
 glub3(li,lj);
 glub4(li,lj);
 if (ki-1>0) and (kj-2>0) then a[ki-1,kj-2]:=1;
 if (ki-1>0) and (kj+2<9) then a[ki-1,kj+2]:=1;
 if (ki-2>0) and (kj-1>0) then a[ki-2,kj-1]:=1;
 if (ki-2>0) and (kj+1<9) then a[ki-2,kj+1]:=1;
 if (ki+1<9) and (kj-2>0) then a[ki+1,kj-2]:=1;
 if (ki+1<9) and (kj+2<9) then a[ki+1,kj+2]:=1;
 if (ki+2<9) and (kj+1<9) then a[ki+2,kj+1]:=1;
 if (ki+2<9) and (kj-1>0) then a[ki+2,kj-1]:=1;
 if (li-1>0) and (lj-2>0) then a[li-1,lj-2]:=1;
 if (li-1>0) and (lj+2<9) then a[li-1,lj+2]:=1;
 if (li-2>0) and (lj-1>0) then a[li-2,lj-1]:=1;
 if (li-2>0) and (lj+1<9) then a[li-2,lj+1]:=1;
 if (li+1<9) and (lj-2>0) then a[li+1,lj-2]:=1;
 if (li+1<9) and (lj+2<9) then a[li+1,lj+2]:=1;
 if (li+2<9) and (lj+1<9) then a[li+2,lj+1]:=1;
 if (li+2<9) and (lj-1>0) then a[li+2,lj-1]:=1;

 answ:=0;
 for i:=1 to 8 do
        begin
        for j:=1 to 8 do
                if a[i,j]=0 then begin inc(answ);write(a[i,j],' ');end;
        writeln;
        end;
 end;

 procedure outputdata;
 begin
 writeln(answ);
 end;

begin
inputdata;
processdata;
outputdata;
end.

const
v:array[1..8,1..2] of longint=((1,2),(2,1),(-1,2),(-1,-2),(-2,1),(-2,-1),(2,-1),(1,-2));

Var
Cuadro:array[-4..12,-4..12] of char;
ren,col:char;
r,c,num1,num2,aux,cont:integer;

begin
Readln(ren,col);
r:=ord(ren)-96;
c:=ord(col)-48;
//1,2
For num1:=1 to 8 do
    begin
    Cuadro[num1,c]:='x';
    Cuadro[c,num1]:='x';
    end;
For num1:=1 to 8 do
    begin
    Cuadro[r+v[num1,1],c+v[num1,2]]:='x';
    end;

//tORRE lista

Readln(ren,col);
r:=ord(ren)-96;
c:=ord(col)-48;
Cuadro[r,c]:='x';
For num1:=1 to 8 do
    begin
    Cuadro[r+v[num1,1],c+v[num1,2]]:='x';
    end;
//caballo listo
cont:=0;
For num1:=1 to 8 do
    For num2:=1 to 8 do
        begin
        If Cuadro[num1,num2]<>'x' then
            cont:=cont+1;
        end;

Writeln(cont);
end.

{$apptype console}

const d : array [1..8, 1..2] of integer = ((1,2),(1,-2),(-1,2),(-1,-2),(2,1),(2,-1),(-2,1),(-2,-1));

var lx, ly, kx, ky: integer;
    m : array [1..8, 1..8] of boolean;
    t : string;

procedure conv( const s : string; var x, y : integer );
begin
   x := ord(s[2]) - ord('1') + 1;
   y := ord(s[1]) - ord('a') + 1;
end;

procedure Mark( x, y : integer );
begin
  if( x>=1) and(y>=1) and (x<=8) and(y<=8 ) then m[y][x] := false;
end;

function Check( x0, y0 : integer ) : boolean;
var i, x, y : integer;
begin
  result := true;
  for i := 1 to 8 do begin
     x := x0 + d[i][1];
     y := y0 + d[i][2];
     if ((x=lx)and(y=ly)) then begin result := false; break; end;
  end;
end;

var x,y, i, s : integer;
begin
  readln( t );
  Conv( t, lx, ly );
  readln( t );
  Conv( t, kx, ky );
{}
  for x := 1 to 8 do
     for y := 1 to 8 do
        if (x = lx ) or (y=ly ) then m[y][x]:=false else m[y][x] := true;

  m[ky][kx] := false;
  for i := 1 to 8 do Mark( kx + d[i][1], ky + d[i][2] );
{}
  s := 0;
  for x := 1 to 8 do
     for y := 1 to 8 do
        if m[y][x] and Check( y,x ) then inc( s );
{}
  write( s );
end.

var
a:array [1..8,1..8] of boolean;
c,code,d1,d,i,j,y1,y2,x1,x2:longint;
q,w,e,r:char;
begin
 c:=0;
 readln(q,w);
 read(e,r);
 x1:=ord(q)-96;
 x2:=ord(e)-96;
 val(w,y1,code);
 val(r,y2,code);
 a[x1,y1]:=true;
 a[x2,y2]:=true;
 for i:=1 to 8 do
 for j:=1 to 8 do
  begin
   d:=abs((i-x1)*(j-y1));
   d1:=abs((i-x2)*(j-y2));
   if (d=2)or(d1=2)or(x1=i)or(x2=j) then a[i,j]:=true;
  end;
 for i:=1 to 8 do
 for j:=1 to 8 do
 if a[i,j]=false then inc(c);
 write(c+1);
end.

const
v:array[1..8,1..2] of longint=((1,2),(2,1),(-1,2),(-1,-2),(-2,1),(-2,-1),(2,-1),(1,-2));

Var
Cuadro:array[-4..12,-4..12] of char;
ren,col:char;
r,c,num1,num2,aux,cont:integer;

begin
Readln(ren,col);
r:=ord(ren)-96;
c:=ord(col)-48;
//1,2
For num1:=1 to 8 do
    begin
    Cuadro[num1,c]:='x';
    Cuadro[c,num1]:='x';
    end;
For num1:=1 to 8 do
    begin
    Cuadro[r+v[num1,1],c+v[num1,2]]:='x';
    end;

//tORRE lista

Readln(ren,col);
r:=ord(ren)-96;
c:=ord(col)-48;

For num1:=1 to 8 do
    begin
    Cuadro[r+v[num1,1],c+v[num1,2]]:='x';
    end;
//caballo listo
cont:=0;
For num1:=1 to 8 do
    For num2:=1 to 8 do
        begin
        If Cuadro[num1,num2]<>'x' then
            cont:=cont+1;
        end;

Writeln(cont-1);
end.

var x,y,x3,y3,kol,x1,x2,y1,y2:longint;
    a:array[0..9,0..9] of longint;
    pp1,pp2:boolean;
    s1,s2:string;
begin
readln(s1);
readln(s2);
x1:=ord(s1[2])-ord('1')+1;
y1:=ord(s1[1])-ord('a')+1;
x2:=ord(s2[2])-ord('1')+1;
y2:=ord(s2[1])-ord('a')+1;
kol:=0;
for x3:= 1 to 8 do
for y3:= 1 to 8 do
begin
if (x1=x3) and (y1=y3) then continue;
if (y2=y3) and (x2=x3) then continue;
pp1:=(x1=x3) or (Y1=y3);
if pp1 then continue;
pp2:=((abs(x2-x3)=2) and (abs(y2-y3)=1)) or
     ((abs(x2-x3)=1) and (abs(y2-y3)=2));
if pp2 then continue;
inc(kol);
end;
writeln(kol-2);
end.

var
  x,y:char;
  a:array[1..8,1..8] of boolean;
  i,j,q1,q2,s:longint;
begin
  fillchar(a,sizeof(a),true);
  readln(x,y);
  q1:=ord(x)-96;q2:=ord(y)-48;
  a[q1,q2]:=false;
  for i:=q1+1 to 8 do a[i,q2]:=false;
  for i:=q1-1 downto 1 do a[i,q2]:=false;
  for i:=q2+1 to 8 do a[q1,i]:=false;
  for i:=q2-1 downto 1 do a[q1,i]:=false;
  readln(x,y);
  q1:=ord(x)-96;q2:=ord(y)-48;
  a[q1,q2]:=false;
  if (q1-2>0) and (q2-1>0) then a[q1-2,q2-1]:=false;
  if (q1-2>0) and (q2+1<=8) then a[q1-2,q2+1]:=false;
  if (q1-1>0) and (q2-2>0) then a[q1-1,q2-2]:=false;
  if (q1-1>0) and (q2+2<=8) then a[q1-1,q2+2]:=false;
  if (q1+1<=8) and (q2-2>0) then a[q1+1,q2-2]:=false;
  if (q1+1<=8) and (q2+2<=8) then a[q1+1,q2+2]:=false;
  if (q1+2<=8) and (q2-1>0) then a[q1+2,q2-1]:=false;
  if (q1+2<=8) and (q2+1<=8) then a[q1+2,q2+1]:=false;
  for i:=1 to 8 do
    for j:=1 to 8 do if a[i,j] then inc(s);
  writeln(s);
end.

var
  x,y:char;
  a:array[1..8,1..8] of boolean;
  i,j,q1,q2,s:longint;
begin
  fillchar(a,sizeof(a),true);
  readln(x,y);
  q1:=ord(x)-96;q2:=ord(y)-48;
  a[q1,q2]:=false;
  for i:=q1+1 to 8 do a[i,q2]:=false;
  for i:=q1-1 downto 1 do a[i,q2]:=false;
  for i:=q2+1 to 8 do a[q1,i]:=false;
  for i:=q2-1 downto 1 do a[q1,i]:=false;
  readln(x,y);
  q1:=ord(x)-96;q2:=ord(y)-48;
  a[q1,q2]:=false;
  if (q1-2>0) and (q2-1>0) then a[q1-2,q2-1]:=false;
  if (q1-2>0) and (q2+1<=8) then a[q1-2,q2+1]:=false;
  if (q1-1>0) and (q2-2>0) then a[q1-1,q2-2]:=false;
  if (q1-1>0) and (q2+2<=8) then a[q1-1,q2+2]:=false;
  if (q1+1<=8) and (q2-2>0) then a[q1+1,q2-2]:=false;
  if (q1+1<=8) and (q2+2<=8) then a[q1+1,q2+2]:=false;
  if (q1+2<=8) and (q2-1>0) then a[q1+2,q2-1]:=false;
  if (q1+2<=8) and (q2+1<=8) then a[q1+2,q2+1]:=false;
  for i:=1 to 8 do
    begin
      for j:=1 to 8 do
        if a[i,j] then write('1 ') else write('0 ');
      writeln;
    end;
  for i:=1 to 8 do
    for j:=1 to 8 do if a[i,j] then inc(s);
  writeln(s);
end.

program Project1;

{$APPTYPE CONSOLE}
{$O-}

uses
  SysUtils;

const
  dx: array[1..8]of longint=(2, 2, -2, -2, 1, 1, -1, -1);
  dy: array[1..8]of longint=(1, -1, 1, -1, 2, -2, 2, -2);
var
  a:array [-1..10, -1..10] of boolean;
  ch1,ch2:Char;
  r, c, j, k, i, rx, ry, kx, ky: longint;
begin                               {
  reset(input,'input.txt');
  rewrite(output,'output.txt');    }

  read(ch1, ch2);
  case ch1 of
    'a': rx:= 1;
    'b': rx:= 2;
    'c': rx:= 3;
    'd': rx:= 4;
    'e': rx:= 5;
    'f': rx:= 6;
    'g': rx:= 7;
    'h': rx:= 8;
  end;
  ry:= strtoint(ch2);

  readln;
  c:= 0;
  read(ch1, ch2);
  case ch1 of
    'a': kx:= 1;
    'b': kx:= 2;
    'c': kx:= 3;
    'd': kx:= 4;
    'e': kx:= 5;
    'f': kx:= 6;
    'g': kx:= 7;
    'h': kx:= 8;
  end;
  ky:= strtoint(ch2);

  for i:= 1 to 8 do
    for j:= 1 to 8 do
      a[i, j]:= true;

  a[rx, ry]:= false;
  for i:= 1 to 8 do begin
    a[i, ry]:= false;
    a[rx, i]:= false;
  end;

  a[kx, ky]:= false;
  for i:= 1 to 8 do
    a[kx + dx[i], ky + dy[i]]:= false;
  r:= 0;
  for i:= 1 to 8 do
    for j:= 1 to 8 do begin
      for k:= 1 to 8 do begin
        if not a[i, j] and not a[i + dx[k], j + dy[k]] then
          r:= 1;
      end;
      if r = 0 then inc(c);
      r:= 0;
    end;

  writeln(c - 2);

end.

program shachmat;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var a:array[1..8,1..8]of boolean;
    la,ha,lb,hb,i,j,n:byte;
    s1:string;
begin
  readln(s1);
  la:=ord(s1[1])-96; lb:=ord(s1[2])-48;
  readln(s1);
  ha:=ord(s1[1])-96; hb:=ord(s1[2])-48;
  for i:=1 to 8 do a[la,i]:=true;
  for i:=1 to 8 do a[i,lb]:=true;
  if (la>1)and(lb<7) then a[la-1,lb+2]:=true;
  if (la>2)and(lb<8) then a[la-2,lb+1]:=true;
  if (la>1)and(lb>2) then a[la-1,lb-2]:=true;
  if (la>2)and(lb>1) then a[la-2,lb-1]:=true;
  if (la<8)and(lb<7) then a[la+1,lb+2]:=true;
  if (la<7)and(lb<8) then a[la+2,lb+1]:=true;
  if (la<8)and(lb>2) then a[la+1,lb-2]:=true;
  if (la<7)and(lb>1) then a[la+2,lb-1]:=true;
  a[ha,hb]:=true;
  if (ha>1)and(hb<7) then a[ha-1,lb+2]:=true;
  if (ha>2)and(hb<8) then a[ha-2,hb+1]:=true;
  if (ha>1)and(hb>2) then a[ha-1,hb-2]:=true;
  if (ha>2)and(hb>1) then a[ha-2,hb-1]:=true;
  if (ha<8)and(hb<7) then a[ha+1,hb+2]:=true;
  if (ha<7)and(hb<8) then a[ha+2,hb+1]:=true;
  if (ha<8)and(hb>2) then a[ha+1,hb-2]:=true;
  if (ha<7)and(hb>1) then a[ha+2,hb-1]:=true;

  n:=0;
  for i:=1 to 8 do
    for j:=1 to 8 do if not a[i,j] then n:=n+1;
  writeln(n);
end.

program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

const
  dx: array[1..8] of longint = (-1, 1, 2, 2, 1, -1, -2, -2);
  dy: array[1..8] of longint = (2, 2, 1, -1, -2, -2, -1, 1);
var
  ch1, ch2: char;
  c, k, i1, i2, j1, j2, flag, i, j: longint;
  a: array[-1..10, -1..10] of longint;
begin         {
  reset(input,'input.txt');
  rewrite(output,'output.txt');
               }
  flag:= 0;
  read(ch1);
  read(ch2);
  i1:= ord(ch1) - ord('a') + 1;
  j1:= strtoint(ch2);
  readln;
  read(ch1);
  read(ch2);
  i2:= ord(ch1) - ord('a') + 1;
  j2:= strtoint(ch2);

  for i:= -1 to 10 do begin
    a[0, i]:= 1;
    a[i, 0]:= 1;
    a[9, i]:= 1;
    a[i, 9]:= 1;
    a[-1, i]:= 1;
    a[i, -1]:= 1;
    a[10, i]:= 1;
    a[i, 10]:= 1;
  end;

  for i:= 1 to 8 do begin
    for j:= 1 to 8 do begin
      if (i =  i1) or (j = j1) then a[i, j]:= 1;
    end;
  end;

  a[i2, j2] := 1;
  for i:= 1 to 8 do begin
    a[i2 + dx[i], j2 + dy[i]]:= 1;
  end;

  c:= 0;
  for i:= 1 to 8 do begin
    for j:= 1 to 8 do begin
      if a[i, j] = 1 then continue;
      for k:= 1 to 8 do begin
        if ((i + dx[k] = i1) and (j + dy[k] = j1)) or
        ((i + dx[i] = i2) and (j + dy[k] = j2)) then begin
          flag:= 1;
          break;
        end;
      end;
      if flag = 1 then flag:= 0 else inc(c);
    end;
  end;

  writeln(c);
end.

var
        c:char;
        x1,x2,y1,y2,ans,i,z:longint;
begin
        read(c); x1:=ord(c)-96;
        readln(c); y1:=ord(c)-48;
        read(c); x2:=ord(c)-96;
        read(c); y2:=ord(c)-48;
        for i:=1 to 8 do
                for z:=1 to 8 do
                if (z<>x1)and(i<>y1)and(not((z=x2)and(i=y2))) then
                if (not((z=x2-2)and(i=y2-1)))and(not((z=x2-1)and(i=y2-2)))and(not((z=x2+2)and(i=y2+1)))and(not((z=x2+1)and(i=y2+2)))and(not((z=x2-1)and(i=y2+2)))and(not((z=x2+1)and(i=y2-2)))and(not((z=x2+2)and(i=y2-1)))and(not((z=x2-2)and(i=y2+1)))
                then inc(ans);
        writeln(ans-2);
end.

const
v:array[1..8,1..2]of integer=((-1,-2),(-2,1),(-1,2),(1,2),(2,1),(2,-1),(-2,1),(-2,-1));
var
tabla:array[-2..10,-2..10] of byte;
i,j,k,n,cor,cor2,cora,corb:longint;
c,c2:char;
begin
        read(c);
        readln(cor);
        read(c2);
        readln(cor2);
        cora:=ord(c)-96;
        corb:=ord(c2)-96;
        tabla[cor,cora]:=1;
        tabla[cor2,corb]:=1;
        for i:=1 to 8 do
                tabla[cor2+v[i,1],corb+v[i,2]]:=1;
        for i:=1 to 8 do
        begin
                tabla[i,cor]:=1;
                tabla[cora,i]:=1;
        end;
        for i:=1 to 8 do
                for j:=1 to 8 do
                        if tabla[i,j]=0 then
                        k:=k+1;
        writeln(k-2);
end.

program Project3;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  l,k:string;
  a:array [0..14,0..14] of boolean;
  s,i,j,l1,l2,k1,k2:integer;

procedure kon(x,y:integer);
begin
  a[x+1,y+3]:=true;
  a[x-1,y-3]:=true;
  a[x+1,y-3]:=true;
  a[x-1,y+3]:=true;
  a[x+3,y+1]:=true;
  a[x-3,y-1]:=true;
  a[x+3,y-1]:=true;
  a[x-3,y+1]:=true;
end;

begin
  { TODO -oUser -cConsole Main : Insert code here }
  readln(l);
  read(k);
  l1:=ord(l[1])-ord('a')+3;
  l2:=ord(l[2])-ord('1')+3;
  k1:=ord(k[1])-ord('a')+3;
  k2:=ord(k[2])-ord('1')+3;
  for i:=3 to 10 do a[l1,i]:=true;
  for i:=3 to 10 do a[i,l2]:=true;
  kon(l1,l2);
  kon(k1,k2);
  a[k1,k2]:=true;
  s:=0;
  for i:=3 to 10 do
    for j:=3 to 10 do
      if not a[i,j] then inc(s);

  write(s);

end.

var
 a:array [-10..80,-10..80] of longint;
 i,j,n,m,k,x1,y1,x2,y2,ans:longint;
 s1,s2,s,ss:string;

 procedure print;
  var
   i,j:longint;
  begin
   for i:=1 to 8 do
    begin
     for j:=1 to 8 do
      write(a[i,j]);
     writeln
    end;
  end;

 procedure d1 (x1,y1:longint);
  var
   i,j:longint;
  begin
  i:=x1; j:=y1;
   while (i<>-1)and(j<>-1) do
    begin
      if a[i,j]=-1 then break;
     a[i,j]:=1;
     dec(i);
     dec(j);
    end;
   i:=x1; j:=y1;
    while (i<>-1)and(j<>10) do
     begin
       if a[i,j]=-1 then break;
      a[j,i]:=1;
      dec(i);
      inc(j);
     end;
   print;
  end;

 procedure d2 (x1,y1:longint);
  var
   i,j:longint;
  begin
  i:=x1+1; j:=y1+1;
   while (i<>10)and(j<>10) do
    begin
      if a[i,j]=-1 then break;
     a[i,j]:=1;
     inc(i);
     inc(j);

    end;
   i:=x1+1; j:=y1-1;
   while (i<>10)and(j<>-1) do
    begin
     if a[i,j]=-1 then break;
     a[i,j]:=1;
     inc(i);
     dec(j);

    end;
   print
  end;

 procedure g (x1,y1:longint);
  var
   i,j:longint;
  begin
   i:=y1;
   for j:=1 to 8 do
   begin
    if a[i,j]=-1 then break;
    a[i,j]:=1;
       end;
   print
  end;

 procedure v (x1,y1:longint);
  var
   i,j:longint;
  begin
   i:=x1;
   for j:=1 to 8 do
   begin
    if a[j,i]=-1 then break;
    a[j,i]:=1;
        end;
   print
  end;

 procedure kon(x2,y2:longint);
  var
   i,j:longint;
  begin
   i:=x2; j:=y2;
   a[i+2,j+1]:=1;
   a[i+2,j-1]:=1;
   a[i-2,j+1]:=1;
   a[i-2,j-1]:=1;
   a[i+1,j+2]:=1;
   a[i-1,j+2]:=1;
   a[i+1,j-2]:=1;
   a[i-1,j-2]:=1;
   print
  end;

begin
 readln(s1);
 readln(s2);
 s:='abcdefgh';
 ss:='12345678';
 x1:=pos(s1[1],s);
 x2:=pos(s2[1],s);
 y1:=pos(s1[2],ss);
 y2:=pos(s2[2],ss);
 a[x2,y2]:=1;
 //d1(x1,y1);
// d2(x1,y1);
 g(x1,y1);
 v(x1,y1);
 kon(x2,y2);
 kon(y1,x1);
 for i:=1 to 8 do
  for j:=1 to 8 do
   if a[i,j]<>1 then inc(ans);
  writeln(ans);
end.

const finp='';
      fout='';
var a:array [-1..10,-1..10] of integer;
    r,k:string;
    dem,r1,r2,k1,k2:longint;
procedure nhap;
var f:text;
    x,y:longint;
begin
     assign(f,finp);
     reset(f);
     for x:=1 to 8 do
      for y:=1 to 8 do
       a[x,y]:=0;
     readln(f,r);
     readln(f,k);
     x:=ord(r[1])-96;
     y:=ord(r[2])-48;
     r1:=x; r2:=y;
     a[x,y]:=1;
     x:=ord(k[1])-96;
     y:=ord(k[2])-48;
     k1:=x; k2:=y;
     a[x,y]:=1;
     close(f);
end;
{--------------}
procedure rook;
var x,y:longint;
begin
     for y:=1 to 8 do
      a[r1,y]:=1;
     for x:=1 to 8 do
      a[x,r2]:=1;
end;
{--------------}
procedure knight;
begin
     a[k1+1,k2+2]:=1;
     a[k1+1,k2-2]:=1;
     a[k1+2,k2+1]:=1;
     a[k1+2,k2-1]:=1;
     a[k1-1,k2+2]:=1;
     a[k1-1,k2-2]:=1;
     a[k1-2,k2+1]:=1;
     a[k1-2,k2-1]:=1;
end;
{--------------}
procedure xuli;
var x,y:longint;
begin
     rook;
     knight;
     for x:=1 to 8 do
      for y:=1 to 8 do
       if a[x,y]=0 then inc(dem);
end;
{--------------}
procedure xuat;
var g:text;
begin
     assign(g,fout);
     rewrite(g);
     write(g,dem-2);
     close(g);
end;
{--------------}
begin
     nhap;
     xuli;
     xuat;
end.

program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  marked : array [1..12, 1..12] of boolean;
  hx, hy, lx, ly : integer;
  probs : integer;
  position1, position2 : string;
  c : char;
  i, j : integer;
begin
  { TODO -oUser -cConsole Main : Insert code here }
  readln(position1);
  c := position1[1];
  lx := ord(c) - 96;
  c := position1[2];
  ly := ord(c) - 48;
  readln(position2);
  c := position2[1];
  hx := ord(c) - 96;
  c := position2[2];
  hy := ord(c) - 48;
  for i := 1 to 12 do
    for j := 1 to 12 do
      marked[i,j] := false;
  marked[2 + lx,2 + ly] := true;
  marked[2 + hx,2 + hy] := true;
  for i := 1 to 12 do
  begin
    marked[lx + 2, i] := true;
    marked[i, ly + 2] := true;
  end;
  marked[2 + hx + 2,2 + hy - 1] := true;
  marked[2 + hx - 1,2 + hy - 2] := true;
  marked[2 + hx - 2,2 + hy + 1] := true;
  marked[2 + hx + 1,2 + hy + 2] := true;

  marked[2 + hx + 2,2 + hy + 1] := true;
  marked[2 + hx + 1,2 + hy - 2] := true;
  marked[2 + hx - 2,2 + hy - 1] := true;
  marked[2 + hx - 1,2 + hy + 2] := true;
  probs := 0;
  for i:=3 to 10 do
    for j := 3 to 10 do
     if not(marked[i,j]) then inc(probs);
  probs := probs - 2;
  writeln(probs);
end.

var
  s,s2 : string;
  a,b,c,d,kode,baris,kolom,jum : longint;
  mat : array[-2..10,-2..10] of longint;
begin
  readln(s);
  readln(s2);
  s[1] := chr(ord(s[1])-48);
  s2[1] := chr(ord(s2[1])-48);
  val(s[1],b,kode);
  val(s[2],a,kode);
  val(s2[1],d,kode);
  val(s2[2],c,kode);
  writeln(a,b,c,d);
  mat[a,b] := 1;
  mat[c,d] := 1;
  for baris := 1 to 8 do begin
    for kolom := 1 to 8 do begin
      if (baris = a) or (kolom = b) then mat[baris,kolom] := 1;
    end;
  end;

  mat[c-2,d-1] := 1;
  mat[c-2,d+1] := 1;
  mat[c+2,d+1] := 1;
  mat[c+2,d-1] := 1;
  mat[c-1,d+2] := 1;
  mat[c-1,d-2] := 1;
  mat[c+1,d+2] := 1;
  mat[c+1,d-2] := 1;
  mat[a-2,b-1] := 1;
  mat[a-2,b+1] := 1;
  mat[a+2,b+1] := 1;
  mat[a+2,b-1] := 1;
  mat[a-1,b+2] := 1;
  mat[a-1,b-2] := 1;
  mat[a+1,b+2] := 1;
  mat[a+1,b-2] := 1;
  for baris := 1 to 8 do begin
    for kolom := 1 to 8 do begin
      if mat[baris,kolom] = 0 then inc(jum);
    end;
  end;

  writeln(jum);
end.

program Project2;

{$APPTYPE CONSOLE}

uses
    SysUtils;
var
    n, i, j, x, y, a, b, ans: integer;
    s:string;
    d: array [1 .. 8, 1 .. 8] of boolean;
    dx: array [1 .. 8] of integer = (1, 1, 2, 2, -1, -1, -2, -2);
    dy: array [1 .. 8] of integer = (2, -2, 1, -1, 2, -1, 1, -1);
function check(x1, y1: integer): boolean;
begin
    check := not((x1 > 8) or (y1 > 8) or (y1 < 1) or (x1 < 1));
end;
begin
    n := 8;
    readln(s);
    x := ord(s[1]) - ord('a') + 1;
    y := ord(s[2]) - ord('0');
    readln(s);
    a := ord(s[1]) - ord('a') + 1;
    b := ord(s[2]) - ord('0');
    for i := 1 to n do
        for j := 1 to n do
            d[i, j] := true;
    for i := 1 to 8 do
    begin
        if (check(a + dx[i], b + dy[i])) then
            d[a + dx[i], b + dy[i]] := false;
        if (check(x + dx[i], y + dy[i])) then
            d[x + dx[i], y + dy[i]] := false;
        d[x, i] := false;
        d[i, y] := false;
    end;
    d[a, b] := false;
    d[x, y] := false;
    ans := 0;
    for i := 1 to n do
        for j := 1 to n do
            if d[i, j] then
                inc(ans);
    writeln(ans);
end.

var s:string; i,j,x1,y1,x2,y2,c:longint;
begin
readln(s);
x1:=ord(s[1])-ord('a')+1;
y1:=ord(s[2])-48;
readln(s);
x2:=ord(s[1])-ord('a')+1;
y2:=ord(s[2])-48;
c:=0;
for i:=1 to 8 do
  for j:=1 to 8 do
    if (i=x1) or (j=y1) or ((abs(i-x2)=2) and (abs(j-y2)=1)) or ((abs(i-x2)=1) and (abs(j-y2)=2)) or ((abs(i-x1)=2) and (abs(j-y1)=1)) or ((abs(i-x1)=1) and (abs(j-y1)=2)) and (i=x1) and (i=x2) and (j=y1) and (j=y2) then else inc(c);
writeln(c);
end.

var
a:array [1..8,1..8] of boolean;
c,code,d1,d,i,j,y1,y2,x1,x2:longint;
q,w,e,r:char;
begin
 c:=0;
 readln(q,w);
 read(e,r);
 x1:=ord(q)-96;
 x2:=ord(e)-96;
 val(w,y1,code);
 val(r,y2,code);
 a[x1,y1]:=true;
 a[x2,y2]:=true;
 for i:=1 to 8 do
 for j:=1 to 8 do
  begin
   d:=abs((i-x1)*(j-y1));
   d1:=abs((i-x2)*(j-y2));
   if (d=2)or(d1=2)or(x1=i)or(x2=j) then a[i,j]:=true;
  end;
 for i:=1 to 8 do
 for j:=1 to 8 do
 if a[i,j]=false then inc(c);
 write(c+1);
end.

const
v:array[1..8,1..2] of integer=((-2,-1),(-2,1),(-1,2),(1,2),(2,1),(2,-1),(1,-2),(-1,-2));
var
arr:array[-2..10,-2..10] of boolean;
i,j,n,p:longint;
car:char;
begin
        read (car);
        readln(n);
        for i:=1 to 8 do
                arr[(ord(car)-96+v[i,1]),(n+v[i,2])]:=true;
        for i:=1 to 8 do
                arr[i,(ord(car)-96)]:=true;
        for i:=1 to 8 do
                arr[(ord(car)-96),i]:=true;
        read (car);
        readln (n);
        arr[(ord(car)-96),n]:=true;
        for i:=1 to 8 do
                arr[(ord(car)-96+v[i,1]),(n+v[i,2])]:=true;
        p:=0;
        for i:=1 to 8 do
                for j:=1 to 8 do
                        if not arr[i,j] then
                                inc (p);
        writeln (p);
end.

const
v:array[1..8,1..2] of longint=((1,2),(2,1),(-1,2),(-1,-2),(-2,1),(-2,-1),(2,-1),(1,-2));

Var
Cuadro:array[-4..12,-4..12] of char;
ren,col:char;
r,c,num1,num2,aux,cont:integer;

begin
Readln(ren,col);
r:=ord(ren)-96;
c:=ord(col)-48;
//1,2
For num1:=1 to 8 do
    begin
    Cuadro[num1,c]:='x';
    Cuadro[c,num1]:='x';
    end;
For num1:=1 to 8 do
    begin
    Cuadro[r+v[num1,1],c+v[num1,2]]:='x';
    end;

//tORRE lista

Readln(ren,col);
r:=ord(ren)-96;
c:=ord(col)-48;

For num1:=1 to 8 do
    begin
    Cuadro[r+v[num1,1],c+v[num1,2]]:='x';
    end;
//caballo listo
cont:=0;
For num1:=1 to 8 do
    For num2:=1 to 8 do
        begin
        If Cuadro[num1,num2]<>'x' then
            cont:=cont+1;
        end;

Writeln(cont-1);
end.

const
v:array[1..8,1..2] of longint=((1,2),(2,1),(-1,2),(-1,-2),(-2,1),(-2,-1),(2,-1),(1,-2));

Var
Cuadro:array[-4..12,-4..12] of char;
ren,col:char;
r,c,num1,num2,aux,cont:integer;

begin
Readln(ren,col);
r:=ord(ren)-96;
c:=ord(col)-48;
//1,2
For num1:=1 to 8 do
    begin
    Cuadro[num1,c]:='x';
    Cuadro[c,num1]:='x';
    end;
For num1:=1 to 8 do
    begin
    Cuadro[r+v[num1,1],c+v[num1,2]]:='x';
    end;

//tORRE lista

Readln(ren,col);
r:=ord(ren)-96;
c:=ord(col)-48;
Cuadro[r,c]:='x';
For num1:=1 to 8 do
    begin
    Cuadro[r+v[num1,1],c+v[num1,2]]:='x';
    end;
//caballo listo
cont:=0;
For num1:=1 to 8 do
    For num2:=1 to 8 do
        begin
        If Cuadro[num1,num2]<>'x' then
            cont:=cont+1;
        end;

Writeln(cont);
end.

var s:string; i,j,x1,y1,x2,y2,c:longint;
begin
readln(s);
x1:=ord(s[1])-ord('a')+1;
y1:=ord(s[2])-48;
readln(s);
x2:=ord(s[1])-ord('a')+1;
y2:=ord(s[2])-48;
c:=0;
for i:=1 to 8 do
  for j:=1 to 8 do
    if (i=x1) or (j<>y1) or ((abs(i-x2)=2) and (abs(j-y2)=1)) or ((abs(i-x2)=1) and (abs(j-y2)=2)) then else inc(c);
writeln(c);
end.

const fi = '';
      fo = '';
      f: array['a'..'h'] of longint = (1,2,3,4,5,6,7,8);
var a: array[-1..10,-1..10] of boolean;
    x1, x2: char;
    s: string;
    y1, y2, i, j, ans, e: longint;
begin
  assign(input,fi); reset(input);
  assign(output,fo); rewrite(output);

  fillchar(a,sizeof(a),true);
  readln(x1,s);
  val(s,y1,e);
  readln(x2,s);
  val(s,y2,e);
  a[f[x1],y1]:=false;
  for i:=1 to 8 do
    begin
      a[f[x1],i]:=false;
      a[i,y1]:=false;
    end;

  a[f[x2],y2]:=false;
  a[f[x2]-2,y2-1]:=false;
  a[f[x2]-2,y2+1]:=false;
  a[f[x2]-1,y2-2]:=false;
  a[f[x2]-1,y2+2]:=false;
  a[f[x2]+1,y2-2]:=false;
  a[f[x2]+1,y2+2]:=false;
  a[f[x2]+2,y2-1]:=false;
  a[f[x2]+2,y2+1]:=false;

  ans:=0;
  for i:=1 to 8 do
    for j:=1 to 8 do if a[i,j] then inc(ans);
  writeln(ans-2);

  {for i:=1 to 8 do
    begin
      for j:=1 to 8 do if a[i,j] then write('T ')
      else write('F ');
      writeln;
    end;   }

  close(input); close(output);
end.

const
  steps : array [1..8,1..2] of longint = ((1,2),(2,1),(-1,2),(2,-1),
                                          (-1,-2),(-2,-1),(1,-2),(-2,1));
var
  s1,s2 : string;
  x1,y1,x2,y2,i,j,ans : longint;
  mark : array [-8..16,-8..16] of boolean;
begin
  {assign(input,'input.txt'); reset(input);
  assign(output,'output.txt'); rewrite(output);
  }readln(s1);
  readln(s2);
  x1:=ord(s1[1])-96;
  y1:=ord(s1[2])-48;
  x2:=ord(s2[1])-96;
  y2:=ord(s2[2])-48;
  for i:=1 to 8 do
    begin
      mark[i,x1]:=true;
      mark[y1,i]:=true;
    end;
  for i:=1 to 8 do
    begin
      mark[x1+steps[i,1],y1+steps[i,2]]:=true;
      mark[x2+steps[i,1],y2+steps[i,2]]:=true;
    end;
  ans:=0;
  for i:=1 to 8 do
    for j:=1 to 8 do
      if not mark[i,j] then inc(ans);
  writeln(ans-1);
  close(input); close(output);
end.

const
v:array[1..8,1..2]of integer=((-1,-2),(-2,1),(-1,2),(1,2),(2,1),(2,-1),(-2,1),(-2,-1));
var
tabla:array[-2..10,-2..10] of byte;
i,j,k,n,cor,cor2,cora,corb:longint;
c,c2:char;
begin
        read(c);
        readln(cor);
        read(c2);
        readln(cor2);
        cora:=ord(c)-96;
        corb:=ord(c2)-96;
        tabla[cora,cor]:=1;
        tabla[corb,cor2]:=1;
        for i:=1 to 8 do
                tabla[corb+v[i,1],cor2+v[i,2]]:=1;
        for i:=1 to 8 do
        begin
                tabla[i,cor]:=1;
                tabla[cora,i]:=1;
        end;
        for i:=1 to 8 do
                for j:=1 to 8 do
                        if tabla[i,j]=0 then
                        k:=k+1;
        writeln(k-2);
end.

const
 sy:array[1..8]of shortint=(-2,-2,-1,1,2,2,1,-1);
 sx:array[1..8]of shortint=(-1,1,2,2,1,-1,-2,-2);
var
 s:string;
 f:array[1..8,1..8]of boolean;
 i,j,x,y,x1,y1,k:longint;
begin
 readln(s);
 fillchar(f,sizeof(f),false);
 x:=ord(s[1])-96;
 y:=ord(s[2])-48;
 readln(s);
 x1:=ord(s[1])-96;
 y1:=ord(s[2])-48;
 k:=0;
 f[x1,y1]:=true;
 for i:=x to 8 do f[i,y]:=true;
 for i:=x downto 1 do f[i,y]:=true;
 for i:=y to 8 do f[x,i]:=true;
 for i:=y downto 1 do f[x,i]:=true;
 for i:=1 to 8 do
 begin
  if(sy[i]+y>1)and(sy[i]+y<9)and(sx[i]+x>1)and(sx[i]+x<9)then f[sy[i]+y,sx[i]+x]:=true;
  if(sy[i]+y1>1)and(sy[i]+y1<9)and(sx[i]+x1>1)and(sx[i]+x1<9)then f[sy[i]+y1,sx[i]+x1]:=true;
 end;
 for i:=1to 8 do for j:=1 to 8 do if not f[i,j]then inc(k);
 writeln(k);
end.