#include <bits/stdc++.h>
using namespace std;
void loadData(void);
int proc(void);
void printRes(int);
void solveRook(int x, int y);
void solveKnight(int x, int y);
bool inArea(int x, int y);
int board[8][8];
const int d[8][2] = {{1, 2},   {2, 1},   {2, -1}, {1, -2},
                     {-1, -2}, {-2, -1}, {-2, 1}, {-1, 2}};
int main(int argc, char** argv) {
  loadData();
  printRes(proc());
  return 0;
}
bool inArea(int x, int y) { return x >= 0 && x < 8 && y >= 0 && y < 8; }
void solveRook(int x, int y) {
  for (int i = 0; i < 8; i++) {
    board[x][i] = 1;
    board[i][y] = 1;
  }
  return;
}
void solveKnight(int x, int y) {
  board[x][y] = 1;
  for (int i = 0; i < 8; i++)
    if (inArea(x + d[i][0], y + d[i][1])) board[x + d[i][0]][y + d[i][1]] = 1;
  return;
}
int proc(void) {
  int res = 0;
  for (int i = 0; i < 8; i++)
    for (int j = 0; j < 8; j++)
      if (board[i][j] == 0) res++;
  return res;
}
void loadData(void) {
  memset(board, 0, sizeof(board));
  char input[3], enter;
  int x, y;
  scanf("%s%c", input, &enter);
  x = input[0] - 'a';
  y = input[1] - '1';
  solveRook(x, y);
  solveKnight(x, y);
  scanf("%s%c", input, &enter);
  x = input[0] - 'a';
  y = input[1] - '1';
  solveKnight(x, y);
  return;
}
void printRes(int res) {
  printf("%d\n", res);
  return;
}
