#include <bits/stdc++.h>
using namespace std;
const int N = 8;
const int dxs[] = {2, 1, -1, -2, -2, -1, 1, 2};
const int dys[] = {-1, -2, -2, -1, 1, 2, 2, 1};
char s0[8], s1[8];
bool flds[N][N];
inline void readpos(char s[], int &x, int &y) {
  x = s[0] - 'a';
  y = s[1] - '1';
}
inline void setknight(int x, int y) {
  for (int di = 0; di < 8; di++) {
    int vx = x + dxs[di], vy = y + dys[di];
    if (vx >= 0 && vx < N && vy >= 0 && vy < N) flds[vy][vx] = true;
  }
}
int main() {
  scanf("%s%s", s0, s1);
  int rx, ry, kx, ky;
  readpos(s0, rx, ry);
  readpos(s1, kx, ky);
  flds[ry][rx] = flds[ky][kx] = true;
  for (int x = 0; x < N; x++) flds[ry][x] = true;
  for (int y = 0; y < N; y++) flds[y][rx] = true;
  setknight(kx, ky);
  setknight(rx, ry);
  int cnt = 0;
  for (int y = 0; y < N; y++)
    for (int x = 0; x < N; x++)
      if (!flds[y][x]) cnt++;
  printf("%d\n", cnt);
  return 0;
}
