#include <bits/stdc++.h>
using namespace std;
struct point {
  int x;
  int y;
};
bool isOnRook(point root, point p) { return root.x == p.x || root.y == p.y; }
bool isValidOnBoard(point p) {
  return p.x < 9 && p.x > 0 && p.y > 0 && p.y < 9;
}
bool isOnKnight(point root, point p) {
  return (root.x - 2 == p.x && root.y - 1 == p.y) ||
         (root.x - 2 == p.x && root.y + 1 == p.y) ||
         (root.x - 1 == p.x && root.y + 2 == p.y) ||
         (root.x + 1 == p.x && root.y + 2 == p.y) ||
         (root.x + 2 == p.x && root.y + 1 == p.y) ||
         (root.x + 2 == p.x && root.y - 1 == p.y) ||
         (root.x - 1 == p.x && root.y - 2 == p.y) ||
         (root.x + 1 == p.x && root.y - 2 == p.y) ||
         (root.x == p.x && root.y == p.y);
}
int main() {
  string s, t;
  cin >> s >> t;
  int ans = 64, p1x = s[0] - 'a' + 1, p1y = s[1] - '0', p2x = t[0] - 'a' + 1,
      p2y = t[1] - '0';
  point p1, p2;
  p1.x = p1x, p1.y = p1y;
  p2.x = p2x, p2.y = p2y;
  bool check[9][9] = {0};
  for (int i = 1; i < 9; i++) {
    for (int j = 1; j < 9; j++) {
      point tmp;
      tmp.x = i, tmp.y = j;
      check[i][j] = isOnRook(p1, tmp) || isOnKnight(p2, tmp);
      if (!check[i][j])
        check[i][j] = isOnKnight(tmp, p1) || isOnKnight(tmp, p2);
      ans -= check[i][j];
    }
  }
  cout << ans << endl;
  return 0;
}
