#include <bits/stdc++.h>
using namespace std;
int r1, c1, r2, c2;
int CB[10][10];
int dr[8] = {1, -1, 1, -1, -2, -2, 2, 2};
int dc[8] = {2, 2, -2, -2, -1, 1, -1, 1};
int main() {
  char s[10];
  scanf(" %s", s);
  r1 = s[0] - 'a' + 1;
  c1 = s[1] - '0';
  scanf(" %s", s);
  r2 = s[0] - 'a' + 1;
  c2 = s[1] - '0';
  CB[r1][c1] = 2;
  CB[r2][c2] = 2;
  for (int i = r1, j = c1 + 1; j <= 8; j++) CB[i][j] = 1;
  for (int i = r1, j = c1 - 1; j > 0; j--) CB[i][j] = 1;
  for (int i = r1 + 1, j = c1; i <= 8; i++) CB[i][j] = 1;
  for (int i = r1 - 1, j = c1; i > 0; i--) CB[i][j] = 1;
  for (int i = 0; i < 8; i++) {
    int p = r2 + dr[i];
    int q = c2 + dc[i];
    if (p > 0 && q > 0 && p < 9 && q < 9) CB[p][q] = 1;
  }
  for (int i = 0; i < 8; i++) {
    int p = r1 + dr[i];
    int q = c1 + dc[i];
    if (p > 0 && q > 0 && p < 9 && q < 9) CB[p][q] = 1;
  }
  int cnt = 0;
  for (int i = 1; i <= 8; i++) {
    for (int j = 1; j <= 8; j++) {
      if (CB[i][j] == 0) cnt++;
    }
  }
  printf("%d\n", cnt);
  return 0;
}
