#include <bits/stdc++.h>
using namespace std;
int flag[65][65];
int dx[8] = {-2, -1, 1, 2, 2, 1, -1, -2};
int dy[8] = {1, 2, 2, 1, -1, -2, -2, -1};
int main() {
  char rook[10];
  char knight[10];
  while (scanf("%s%s", rook, knight) != EOF) {
    int pos1, pos2;
    int i, j;
    int sum = 64;
    pos1 = rook[0] - 'a' + 1;
    pos2 = rook[1] - '0';
    for (i = 1; i <= 8; i++) {
      flag[i][pos2] = 1;
      flag[pos1][i] = 1;
    }
    for (i = 0; i < 8; i++) {
      int x = pos1 + dx[i];
      int y = pos2 + dy[i];
      if (x >= 1 && x <= 8 && y >= 1 && y <= 8) flag[x][y] = 1;
    }
    pos1 = knight[0] - 'a' + 1;
    pos2 = knight[1] - '0';
    flag[pos1][pos2] = 1;
    for (i = 0; i < 8; i++) {
      int x = pos1 + dx[i];
      int y = pos2 + dy[i];
      if (x >= 1 && x <= 8 && y >= 1 && y <= 8) flag[x][y] = 1;
    }
    for (i = 1; i <= 8; i++)
      for (j = 1; j <= 8; j++)
        if (flag[i][j] == 1) sum--;
    printf("%d\n", sum);
    memset(flag, 0, sizeof(flag));
  }
  return 0;
}
