#include <bits/stdc++.h>
using std::cin;
using std::cout;
using std::endl;
using std::map;
using std::max;
using std::min;
using std::queue;
using std::sort;
using std::stack;
using std::string;
int main() {
  int vis[10][10] = {0};
  char rook[3] = {0}, knight[3] = {0};
  cin >> rook >> knight;
  rook[0] -= 'a', rook[1] -= '1', knight[0] -= 'a', knight[1] -= '1';
  for (int i = 0; i < 8; i++) vis[rook[0]][i] = 1;
  for (int i = 0; i < 8; i++) vis[i][rook[1]] = 1;
  vis[knight[0]][knight[1]] = 1;
  if (rook[0] - 2 >= 0 && rook[1] - 1 >= 0) vis[rook[0] - 2][rook[1] - 1] = 1;
  if (rook[0] - 2 >= 0 && rook[1] + 1 < 8) vis[rook[0] - 2][rook[1] + 1] = 1;
  if (rook[0] - 1 >= 0 && rook[1] - 2 >= 0) vis[rook[0] - 1][rook[1] - 2] = 1;
  if (rook[0] - 1 >= 0 && rook[1] + 2 < 8) vis[rook[0] - 1][rook[1] + 2] = 1;
  if (rook[0] + 2 < 8 && rook[1] - 1 >= 0) vis[rook[0] + 2][rook[1] - 1] = 1;
  if (rook[0] + 2 < 8 && rook[1] + 1 < 8) vis[rook[0] + 2][rook[1] + 1] = 1;
  if (rook[0] + 1 < 8 && rook[1] + 2 < 8) vis[rook[0] + 1][rook[1] + 2] = 1;
  if (rook[0] + 1 < 8 && rook[1] - 2 >= 0) vis[rook[0] + 1][rook[1] - 2] = 1;
  if (knight[0] - 2 >= 0 && knight[1] - 1 >= 0)
    vis[knight[0] - 2][knight[1] - 1] = 1;
  if (knight[0] - 2 >= 0 && knight[1] + 1 < 8)
    vis[knight[0] - 2][knight[1] + 1] = 1;
  if (knight[0] - 1 >= 0 && knight[1] - 2 >= 0)
    vis[knight[0] - 1][knight[1] - 2] = 1;
  if (knight[0] - 1 >= 0 && knight[1] + 2 < 8)
    vis[knight[0] - 1][knight[1] + 2] = 1;
  if (knight[0] + 2 < 8 && knight[1] - 1 >= 0)
    vis[knight[0] + 2][knight[1] - 1] = 1;
  if (knight[0] + 2 < 8 && knight[1] + 1 < 8)
    vis[knight[0] + 2][knight[1] + 1] = 1;
  if (knight[0] + 1 < 8 && knight[1] + 2 < 8)
    vis[knight[0] + 1][knight[1] + 2] = 1;
  if (knight[0] + 1 < 8 && knight[1] - 2 >= 0)
    vis[knight[0] + 1][knight[1] - 2] = 1;
  int count = 0;
  for (int i = 0; i < 8; i++)
    for (int j = 0; j < 8; j++)
      if (!vis[i][j]) count++;
  cout << count << endl;
  return 0;
}
