#include <bits/stdc++.h>
int main() {
  int i, j, r_x, r_y, k_x, k_y, num = 0;
  char rook[3], knight[3], x[8] = {-2, -2, -1, -1, 1, 1, 2, 2},
                           y[8] = {-1, 1, -2, 2, -2, 2, -1, 1};
  bool ans[8][8];
  memset(ans, true, sizeof(ans));
  scanf("%s%s", rook, knight);
  r_x = rook[0] - 'a';
  r_y = rook[1] - '1';
  k_x = knight[0] - 'a';
  k_y = knight[1] - '1';
  for (i = 0; i < 8; i++) {
    ans[r_x][i] = false;
    ans[i][r_y] = false;
    if (0 <= r_x + x[i] && r_x + x[i] <= 7 && 0 <= r_y + y[i] &&
        r_y + y[i] <= 7)
      ans[r_x + x[i]][r_y + y[i]] = false;
  }
  for (i = 0, ans[k_x][k_y] = false; i < 8; i++)
    if (0 <= k_x + x[i] && k_x + x[i] <= 7 && 0 <= k_y + y[i] &&
        k_y + y[i] <= 7)
      ans[k_x + x[i]][k_y + y[i]] = false;
  for (i = 0; i < 8; i++)
    for (j = 0; j < 8; j++)
      if (ans[i][j]) num++;
  printf("%d\n", num);
  return 0;
}
