#include <bits/stdc++.h>
using namespace std;
int a[8][8];
int main() {
  string s, t;
  cin >> s;
  for (int i = 0; i < 8; i++) a[i][s[0] - 'a'] = 1;
  for (int i = 0; i < 8; i++) a[s[1] - '1'][i] = 1;
  cin >> t;
  a[s[1] - '1'][s[0] - 'a'] = 1;
  int a1 = s[0] - 'a', a2 = t[0] - 'a', b1 = s[1] - '1', b2 = t[1] - '1';
  if (a1 - 2 >= 0 && b1 - 1 >= 0) a[b1 - 1][a1 - 2] = 1;
  if (a2 - 2 >= 0 && b2 - 1 >= 0) a[b2 - 1][a2 - 2] = 1;
  if (a1 + 2 < 8 && b1 - 1 >= 0) a[b1 - 1][a1 + 2] = 1;
  if (a2 + 2 < 8 && b2 - 1 >= 0) a[b2 - 1][a2 + 2] = 1;
  if (a1 + 2 < 8 && b1 + 1 < 8) a[b1 + 1][a1 + 2] = 1;
  if (a2 + 2 < 8 && b2 + 1 < 8) a[b2 + 1][a2 + 2] = 1;
  if (a1 - 2 >= 0 && b1 + 1 < 8) a[b1 + 1][a1 - 2] = 1;
  if (a2 - 2 >= 0 && b2 + 1 < 8) a[b2 + 1][a2 - 2] = 1;
  if (a1 - 1 >= 0 && b1 - 2 >= 0) a[b1 - 2][a1 - 1] = 1;
  if (a2 - 1 >= 0 && b2 - 2 >= 0) a[b2 - 2][a2 - 1] = 1;
  if (a1 + 1 < 8 && b1 - 2 >= 0) a[b1 - 2][a1 + 1] = 1;
  if (a2 + 1 < 8 && b2 - 2 >= 0) a[b2 - 2][a2 + 1] = 1;
  if (a1 + 1 < 8 && b1 + 2 < 8) a[b1 + 2][a1 + 1] = 1;
  if (a2 + 1 < 8 && b2 + 2 < 8) a[b2 + 2][a2 + 1] = 1;
  if (a1 - 1 >= 0 && b1 + 2 < 8) a[b1 + 2][a1 - 1] = 1;
  if (a2 - 1 >= 0 && b2 + 2 < 8) a[b2 + 2][a2 - 1] = 1;
  int qw = 64;
  for (int i = 0; i < 8; i++)
    for (int j = 0; j < 8; j++)
      if (a[i][j] == 1) qw--;
  cout << qw - 1;
  return 0;
}
