#include <bits/stdc++.h>
using namespace std;
template <typename T>
void answer(T ans) {
  cout << ans;
  exit(0);
}
bool beat[8][8];
void addbeat(int r, int c) {
  if (r < 0 || r > 7 || c < 0 || c > 7) return;
  beat[r][c] = true;
}
int tr, tc, cr, cc;
bool beats(int r, int c) {
  if (r < 0 || r > 7 || c < 0 || c > 7) return false;
  return r == tr and c == tc or r == cr and c == cc;
}
int main() {
  char c;
  cin >> c;
  tr = c - 'a';
  cin >> c;
  tc = c - '1';
  cin >> c;
  cr = c - 'a';
  cin >> c;
  cc = c - '1';
  ;
  for (int i = 0; i < 8; i++) {
    beat[tr][i] = true;
    beat[i][tc] = true;
  }
  addbeat(cr, cc);
  addbeat(cr - 2, cc + 1);
  addbeat(cr - 1, cc + 2);
  addbeat(cr + 1, cc + 2);
  addbeat(cr + 2, cc + 1);
  addbeat(cr + 2, cc - 1);
  addbeat(cr + 1, cc - 2);
  addbeat(cr - 1, cc - 2);
  addbeat(cr - 2, cc - 1);
  int ans = 0;
  for (int i = 0; i < 8; i++)
    for (int j = 0; j < 8; j++) {
      if (beat[i][j]) continue;
      if (beats(i, j)) continue;
      if (beats(i - 2, j + 1)) continue;
      if (beats(i - 1, j + 2)) continue;
      if (beats(i + 1, j + 2)) continue;
      if (beats(i + 2, j + 1)) continue;
      if (beats(i + 2, j - 1)) continue;
      if (beats(i + 1, j - 2)) continue;
      if (beats(i - 1, j - 2)) continue;
      if (beats(i - 2, j - 1)) continue;
      ans++;
    }
  cout << ans;
}
