#include <bits/stdc++.h>
using namespace std;
string A, B;
int dx[] = {1, 1, 2, 2, -2, -2, -1, -1};
int dy[] = {2, -2, 1, -1, 1, -1, 2, -2};
bool check(string C) {
  if (C == A || C == B) return 0;
  if (C[0] == A[0] || C[1] == A[1]) return 0;
  for (int i = 0; i < 8; i++) {
    string s;
    s.push_back(B[0] + dx[i]);
    s.push_back(B[1] + dy[i]);
    if (s == C) return 0;
  }
  for (int i = 0; i < 8; i++) {
    string s;
    s.push_back(C[0] + dx[i]);
    s.push_back(C[1] + dy[i]);
    if (s == B || s == A) return 0;
  }
  return 1;
}
int main() {
  cin >> A >> B;
  int ans = 0;
  for (char i = 'a'; i <= 'h'; i++)
    for (char j = '1'; j <= '8'; j++) {
      string s;
      s.push_back(i);
      s.push_back(j);
      ans += check(s);
    }
  cout << ans << endl;
  return 0;
}
