#include <bits/stdc++.h>
using namespace std;
char tmp;
int a;
char mat[8][8];
int kx, ky;
int rx, ry;
int d[8][2] = {{1, 2}, {-1, 2}, {-1, -2}, {1, -2},
               {2, 1}, {2, -1}, {-2, -1}, {-2, 1}};
int dx, dy;
int pos;
int fl;
int att[8][2];
int nAtt;
int main() {
  for (int i = 0; i < 8; i++)
    for (int j = 0; j < 8; j++) mat[i][j] = '.';
  scanf(" %c", &tmp);
  scanf("%d", &a);
  a--;
  mat[tmp - 'a'][a] = 'R';
  rx = tmp - 'a';
  ry = a;
  scanf(" %c", &tmp);
  scanf("%d", &a);
  a--;
  mat[tmp - 'a'][a] = 'K';
  kx = tmp - 'a';
  ky = a;
  ;
  ;
  for (int k = 0; k < 8; k++) {
    dx = kx + d[k][0];
    dy = ky + d[k][1];
    if (dx < 0 || dx >= 8) continue;
    if (dy < 0 || dy >= 8) continue;
    att[nAtt][0] = dx;
    att[nAtt][1] = dy;
    nAtt++;
  }
  pos = 0;
  for (int i = 0; i < 8; i++)
    for (int j = 0; j < 8; j++) {
      if (mat[i][j] != '.') continue;
      fl = 0;
      for (int k = 0; k < 8; k++) {
        dx = i + d[k][0];
        dy = j + d[k][1];
        if (dx < 0 || dx >= 8) continue;
        if (dy < 0 || dy >= 8) continue;
        if (mat[dx][dy] != '.') {
          fl = 1;
          break;
        }
      }
      if (fl) continue;
      for (int k = 0; k < nAtt; k++) {
        if (att[k][0] == i && att[k][1] == j) {
          fl = 1;
          break;
        }
      }
      if (fl) continue;
      if (i == rx) continue;
      if (j == ry) continue;
      pos++;
    }
  printf("%d\n", pos);
  return 0;
}
