#include <bits/stdc++.h>
int main(void) {
  int matrix[12][12];
  memset(matrix, 0, sizeof(matrix));
  int i;
  char s[3];
  int col_r, row_r, col_k, row_k;
  scanf("%s", s);
  col_r = s[0] - 'a' + 2;
  row_r = s[1] - '1' + 2;
  scanf("%s", s);
  col_k = s[0] - 'a' + 2;
  row_k = s[1] - '1' + 2;
  for (i = 2; i < 10; i++) {
    matrix[row_r][i] = 1;
    matrix[i][col_r] = 1;
  }
  matrix[row_k][col_k] = 1;
  matrix[row_k - 1][col_k + 2] = 1;
  matrix[row_k - 1][col_k - 2] = 1;
  matrix[row_k + 1][col_k - 2] = 1;
  matrix[row_k + 1][col_k + 2] = 1;
  matrix[row_k - 2][col_k + 1] = 1;
  matrix[row_k - 2][col_k - 1] = 1;
  matrix[row_k + 2][col_k + 1] = 1;
  matrix[row_k + 2][col_k - 1] = 1;
  matrix[row_r - 1][col_r + 2] = 1;
  matrix[row_r - 1][col_r - 2] = 1;
  matrix[row_r + 1][col_r + 2] = 1;
  matrix[row_r + 1][col_r - 2] = 1;
  matrix[row_r - 2][col_r + 1] = 1;
  matrix[row_r - 2][col_r - 1] = 1;
  matrix[row_r + 2][col_r + 1] = 1;
  matrix[row_r + 2][col_r - 1] = 1;
  int j, sum = 0;
  for (i = 2; i < 10; i++)
    for (j = 2; j < 10; j++)
      if (matrix[i][j] == 0) sum++;
  printf("%d\n", sum);
  return 0;
}
