#include <bits/stdc++.h>
using namespace std;
int dir[8][2] = {-1, -2, -1, 2, 1, -2, 1, 2, 2, -1, 2, 1, -2, -1, -2, 1};
int vis[10][10];
int main() {
  memset(vis, 0, sizeof(vis));
  char c1[3], c2[3];
  scanf("%s", c1);
  scanf("%s", c2);
  int x1 = c1[0] - 'a';
  int y1 = c1[1] - '1';
  vis[x1][y1] = 1;
  for (int i = 0; i < 8; i++) vis[i][y1] = 1, vis[x1][i] = 1;
  for (int i = 0; i < 8; i++) {
    int x = x1 + dir[i][0];
    int y = y1 + dir[i][1];
    if (x >= 0 && x < 8 && y >= 0 && y < 8) vis[x][y] = 1;
  }
  int x2 = c2[0] - 'a';
  int y2 = c2[1] - '1';
  vis[x2][y2] = 1;
  for (int i = 0; i < 8; i++) {
    int x = x2 + dir[i][0];
    int y = y2 + dir[i][1];
    if (x >= 0 && x < 8 && y >= 0 && y < 8) vis[x][y] = 1;
  }
  int rst = 0;
  for (int i = 0; i < 8; i++)
    for (int j = 0; j < 8; j++)
      if (!vis[i][j]) rst++;
  printf("%d\n", rst);
  return 0;
}
