#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > a;
void lad(int e, int b) {
  int i;
  for (i = 1; i < 9; i++) a.push_back(make_pair(i, b));
  for (i = 1; i < 9; i++) a.push_back(make_pair(e, i));
  a.push_back(make_pair(e + 1, b + 2));
  a.push_back(make_pair(e + 2, b + 1));
  a.push_back(make_pair(e + 2, b - 1));
  a.push_back(make_pair(e + 1, b - 2));
  a.push_back(make_pair(e - 1, b - 2));
  a.push_back(make_pair(e - 2, b - 1));
  a.push_back(make_pair(e - 2, b + 1));
  a.push_back(make_pair(e - 1, b + 2));
  return;
}
void kon(int c, int d) {
  a.push_back(make_pair(c + 1, d + 2));
  a.push_back(make_pair(c + 2, d + 1));
  a.push_back(make_pair(c + 2, d - 1));
  a.push_back(make_pair(c + 1, d - 2));
  a.push_back(make_pair(c - 1, d - 2));
  a.push_back(make_pair(c - 2, d - 1));
  a.push_back(make_pair(c - 2, d + 1));
  a.push_back(make_pair(c - 1, d + 2));
}
int search() {
  int i, k = 0;
  sort(a.begin(), a.begin() + a.size());
  a.push_back(make_pair(100, 100));
  for (i = 0; i < a.size() - 1; i++)
    if (a[i].first > 0 && a[i].first < 9 && a[i].second > 0 && a[i].second < 9)
      if (a[i].first != a[i + 1].first || a[i].second != a[i + 1].second) k++;
  return 64 - k;
}
int main() {
  int e, b, c, d;
  int p, k, ans;
  char w;
  cin >> w >> b;
  p = w - 'a' + 1;
  e = p;
  cin >> w >> d;
  p = w - 'a' + 1;
  c = p;
  lad(e, b);
  kon(c, d);
  ans = search();
  cout << ans - 1;
  return 0;
}
