#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
#pragma warning(disable : 4996)
using namespace std;
int main() {
  int Lpos1, Lpos2;
  bool p[9][9];
  memset(p, true, sizeof(p));
  for (int i = 0; i < 2; i++) {
    char k[3];
    scanf("%s", &k);
    int pos1 = k[0] - 'a' + 1;
    int pos2 = k[1] - '0';
    if (i == 0) {
      Lpos1 = pos1;
      Lpos2 = pos2;
      for (int j = pos1; j >= 1; j--) p[j][pos2] = false;
      for (int j = pos1; j <= 8; j++) p[j][pos2] = false;
      for (int j = pos2; j >= 1; j--) p[pos1][j] = false;
      for (int j = pos2; j <= 8; j++) p[pos1][j] = false;
    } else {
      int x = pos1, y = pos2;
      p[x][y] = false;
      if (x + 1 <= 8 && y + 2 <= 8) p[x + 1][y + 2] = false;
      if (x - 1 >= 1 && y + 2 <= 8) p[x - 1][y + 2] = false;
      if (x - 2 >= 1 && y + 1 <= 8) p[x - 2][y + 1] = false;
      if (x - 2 >= 1 && y - 1 >= 1) p[x - 2][y - 1] = false;
      if (x - 1 >= 1 && y - 2 >= 1) p[x - 1][y - 2] = false;
      if (x + 1 <= 8 && y - 2 >= 1) p[x + 1][y - 2] = false;
      if (x + 2 <= 8 && y - 1 >= 1) p[x + 2][y - 1] = false;
      if (x + 2 <= 8 && y + 1 <= 8) p[x + 2][y + 1] = false;
    }
  }
  int x = Lpos1, y = Lpos2;
  if (x + 1 <= 8 && y + 2 <= 8) p[x + 1][y + 2] = false;
  if (x - 1 >= 1 && y + 2 <= 8) p[x - 1][y + 2] = false;
  if (x - 2 >= 1 && y + 1 <= 8) p[x - 2][y + 1] = false;
  if (x - 2 >= 1 && y - 1 >= 1) p[x - 2][y - 1] = false;
  if (x - 1 >= 1 && y - 2 >= 1) p[x - 1][y - 2] = false;
  if (x + 1 <= 8 && y - 2 >= 1) p[x + 1][y - 2] = false;
  if (x + 2 <= 8 && y - 1 >= 1) p[x + 2][y - 1] = false;
  if (x + 2 <= 8 && y + 1 <= 8) p[x + 2][y + 1] = false;
  int d = 0;
  for (int i = 1; i <= 8; i++)
    for (int j = 1; j <= 8; j++)
      if (p[i][j]) d++;
  printf("%d", d);
  return 0;
}
