#include <bits/stdc++.h>
struct coord {
  int f, c;
};
struct coord posicion(char* pos, char abc[8]);
int marcar(int esc[][8], int aux[][2], struct coord T, struct coord C);
void vaciar_matriz(int esc[][8], int m, int n);
int main() {
  int aux[8][2] = {{-1, 2}, {-2, 1}, {-2, -1}, {-1, -2},
                   {1, -2}, {2, -1}, {2, 1},   {1, 2}};
  char abc[] = "aabcdefgh";
  char posC[2];
  char posT[2];
  int i;
  struct coord T, C;
  int esc[8][8];
  scanf("%s", posT);
  T = posicion(posT, abc);
  scanf("%s", posC);
  C = posicion(posC, abc);
  vaciar_matriz(esc, 8, 8);
  i = marcar(esc, aux, T, C);
  printf("\n%d", 64 - i);
  return 0;
}
void vaciar_matriz(int esc[][8], int m, int n) {
  int i, j;
  for (i = 0; i < m; i++) {
    for (j = 0; j < n; j++) {
      esc[i][j] = 0;
    }
  }
}
struct coord posicion(char* pos, char abc[8]) {
  struct coord v;
  int i;
  for (i = 1; i <= 8; i++) {
    if (pos[0] == abc[i]) {
      v.c = i - 1;
      break;
    }
  }
  v.f = 7 - (atoi(&pos[1]) - 1);
  return v;
}
int marcar(int esc[][8], int aux[][2], struct coord T, struct coord C) {
  int f, c, i, cont;
  esc[T.f][T.c] = -2;
  esc[C.f][C.c] = -2;
  cont = 2;
  for (i = 0; i < 8; i++) {
    if (!esc[T.f][i]) {
      esc[T.f][i] = -1;
      cont++;
    }
    if (!esc[i][T.c]) {
      esc[i][T.c] = -1;
      cont++;
    }
    f = aux[i][0] + C.f;
    c = aux[i][1] + C.c;
    if (f >= 0 && f < 8 && c >= 0 && c < 8) {
      if (!esc[f][c]) {
        esc[f][c] = -1;
        cont++;
      }
    }
    f = aux[i][0] + T.f;
    c = aux[i][1] + T.c;
    if (f >= 0 && f < 8 && c >= 0 && c < 8) {
      if (!esc[f][c]) {
        esc[f][c] = -1;
        cont++;
      }
    }
  }
  return cont;
}
