#include <bits/stdc++.h>
using namespace std;
bool d[20][20];
char ch, ch2;
int a, b, a2, b2, ans;
void start() {
  cin >> ch >> ch2;
  a = ch - 96;
  a2 = ch2 - 48;
  cin >> ch >> ch2;
  b = ch - 96;
  b2 = ch2 - 48;
}
void solve() {
  for (int i = 1; i <= 8; i++)
    for (int j = 1; j <= 8; j++) d[i][j] = false;
  d[a][a2] = true;
  d[b][b2] = true;
  for (int x = 1; x <= 8; x++) {
    d[a][x] = true;
    d[x][a2] = true;
  }
  if (b - 2 > 0 && b2 - 1 > 0) d[b - 2][b2 - 1] = true;
  if (b - 2 > 0) d[b - 2][b2 + 1] = true;
  if (b - 1 > 0 && b2 - 2 > 0) d[b - 1][b2 - 2] = true;
  if (b - 1 > 0) d[b - 1][b2 + 2] = true;
  if (b2 - 2 > 0) d[b + 1][b2 - 2] = true;
  d[b + 1][b2 + 2] = true;
  if (b2 - 1 > 0) d[b + 2][b2 - 1] = true;
  d[b + 2][b2 + 1] = true;
  if (a - 2 > 0 && a2 - 1 > 0) d[a - 2][a2 - 1] = true;
  if (a - 2 > 0) d[a - 2][a2 + 1] = true;
  if (a - 1 > 0 && a2 - 2 > 0) d[a - 1][a2 - 2] = true;
  if (a - 1 > 0) d[a - 1][a2 + 2] = true;
  if (a2 - 2 > 0) d[a + 1][a2 - 2] = true;
  d[a + 1][a2 + 2] = true;
  if (a2 - 1 > 0) d[a + 2][a2 - 1] = true;
  d[a + 2][a2 + 1] = true;
}
void finish() {
  ans = 0;
  for (int i = 1; i <= 8; i++)
    for (int j = 1; j <= 8; j++)
      if (!d[i][j]) ans++;
}
int main() {
  start();
  solve();
  finish();
  cout << ans;
  return 0;
}
