#include <bits/stdc++.h>
int mx[8] = {-2, -2, -1, -1, 1, 1, 2, 2};
int my[8] = {-1, 1, -2, 2, -2, 2, -1, 1};
int main() {
  int map[10][10] = {0};
  int x1, y1, x2, y2;
  char pos1[100] = {0}, pos2[100] = {0};
  scanf("%s", pos1);
  scanf("%s", pos2);
  x1 = pos1[0] - 'a';
  y1 = pos1[1] - '1';
  x2 = pos2[0] - 'a';
  y2 = pos2[1] - '1';
  map[x1][y1] = 256;
  map[x2][y2] = 512;
  for (int i = 0; i < 8; i++) {
    if (map[x1][i] == 512 || map[i][y1] == 512) {
      printf("0");
      return 0;
    } else
      map[x1][i] = ++map[i][y1];
  }
  for (int i = 0; i < 8; i++) {
    if (x2 + mx[i] >= 0 && x2 + mx[i] < 8 && y2 + my[i] >= 0 &&
        y2 + my[i] < 8) {
      if (map[x2 + mx[i]][y2 + my[i]] == 256) {
        printf("0");
        return 0;
      } else
        map[x2 + mx[i]][y2 + my[i]]++;
    }
  }
  for (int i = 0; i < 8; i++)
    if (x1 + mx[i] >= 0 && x1 + mx[i] < 8 && y1 + my[i] >= 0 && y1 + my[i] < 8)
      map[x1 + mx[i]][y1 + my[i]]++;
  int ans = 0;
  for (int i = 0; i < 8; i++)
    for (int j = 0; j < 8; j++)
      if (map[i][j] == 0) ans++;
  printf("%d", ans);
  return 0;
}
