#include <bits/stdc++.h>
using namespace std;
int dx[] = {-2, -2, -1, -1, 1, 1, 2, 2};
int dy[] = {1, -1, 2, -2, 2, -2, 1, -1};
bool UnderAttack[8][8];
int cnt = 0, inc;
bool Inside(int x, int y) { return (x >= 0 && x < 8 && y >= 0 && y < 8); }
int main() {
  int x1, y1, x2, y2;
  char c1, c2, c3, c4;
  scanf("%c%c\n%c%c", &c1, &c2, &c3, &c4);
  x1 = c1 - 'a';
  y1 = c2 - '1';
  x2 = c3 - 'a';
  y2 = c4 - '1';
  UnderAttack[y2][x2] = true;
  for (int i = 0; i < 8; i++) {
    for (int j = 0; j < 8; j++) {
      if (i == y1 || j == x1) UnderAttack[i][j] = true;
      for (int k = 0; k < 8; k++) {
        if (Inside(x2 + dx[k], y2 + dy[k]) && j == x2 + dx[k] &&
            i == y2 + dy[k])
          UnderAttack[i][j] = true;
      }
    }
  }
  for (int i = 0; i < 8; i++) {
    for (int j = 0; j < 8; j++) {
      inc = 1;
      if (!UnderAttack[i][j]) {
        for (int k = 0; k < 8; k++) {
          if (Inside(j + dx[k], i + dy[k]) &&
              (j + dx[k] == x1 && i + dy[k] == y1 ||
               j + dx[k] == x2 && i + dy[k] == y2))
            inc = 0;
        }
        cnt += inc;
      }
    }
  }
  cout << cnt;
  return 0;
}
