#include <bits/stdc++.h>
int pos[8][2] = {{2, 1},   {1, 2},   {-1, 2}, {-2, 1},
                 {-2, -1}, {-1, -2}, {1, -2}, {2, -1}};
int CtoI(char);
void marcarCaballo(int tab[8][8], int f, int c);
void marcarTorre(int tab[8][8], int f, int c);
int ataca(int tab[8][8], int f, int c);
int main() {
  char posT[3];
  char posC[3];
  scanf("%s", posT);
  scanf("%s", posC);
  int fT = CtoI(posT[0]);
  int cT = CtoI(posT[1]);
  int fC = CtoI(posC[0]);
  int cC = CtoI(posC[1]);
  int tabl[8][8] = {0};
  tabl[fC][cC] = 2;
  tabl[fT][cT] = 2;
  marcarCaballo(tabl, fC, cC);
  marcarTorre(tabl, fT, cT);
  int resu = 0;
  int i, j;
  for (i = 0; i < 8; i++) {
    for (j = 0; j < 8; j++) {
      if (tabl[i][j] == 0) {
        if (!ataca(tabl, i, j)) {
          resu++;
        }
      }
    }
  }
  printf("%d", resu);
  return 0;
}
int ataca(int tab[8][8], int f, int c) {
  int i;
  for (i = 0; i < 8; i++) {
    if ((f + pos[i][0] < 8 && f + pos[i][0] >= 0) &&
        (c + pos[i][1] < 8 && c + pos[i][1] >= 0)) {
      if (tab[f + pos[i][0]][c + pos[i][1]] == 2) return 1;
    }
  }
  return 0;
}
void marcarCaballo(int tab[8][8], int f, int c) {
  int i;
  for (i = 0; i < 8; i++) {
    if ((f + pos[i][0] < 8 && f + pos[i][0] >= 0) &&
        (c + pos[i][1] < 8 && c + pos[i][1] >= 0)) {
      if (tab[f + pos[i][0]][c + pos[i][1]] == 0)
        tab[f + pos[i][0]][c + pos[i][1]] = 1;
    }
  }
}
void marcarTorre(int tab[8][8], int f, int c) {
  int i;
  for (i = 0; i < 8; i++) {
    if (tab[i][c] == 0) {
      tab[i][c] = 1;
    }
    if (tab[f][i] == 0) {
      tab[f][i] = 1;
    }
  }
}
int CtoI(char C) {
  switch (C) {
    case '1':
    case 'a':
      return 0;
      break;
    case '2':
    case 'b':
      return 1;
      break;
    case '3':
    case 'c':
      return 2;
      break;
    case '4':
    case 'd':
      return 3;
      break;
    case '5':
    case 'e':
      return 4;
      break;
    case '6':
    case 'f':
      return 5;
      break;
    case '7':
    case 'g':
      return 6;
      break;
    case '8':
    case 'h':
      return 7;
  }
}
