#include <bits/stdc++.h>
using namespace std;
const int dx[] = {-2, -2, -1, 1, 2, 2, 1, -1};
const int dy[] = {-1, 1, 2, 2, 1, -1, -2, -2};
int i, d[8][8], x, y, xx, yy, j, rs;
string a, b;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> a >> b;
  y = a[0] - 'a';
  x = a[1] - '1';
  yy = b[0] - 'a';
  xx = b[1] - '1';
  for (i = 0; i < 8; ++i) d[x][i] = d[i][y] = 1;
  d[xx][yy] = 1;
  for (i = 0; i < 8; ++i) {
    int nx = xx + dx[i];
    int ny = yy + dy[i];
    if (nx < 0 || nx > 7) continue;
    if (ny < 0 || ny > 7) continue;
    d[nx][ny] = 1;
  }
  for (i = 0; i < 8; ++i)
    for (j = 0; j < 8; ++j) {
      if (d[i][j]) continue;
      bool ok = 1;
      for (int k = 0; k < 8; ++k) {
        int nx = i + dx[k];
        int ny = j + dy[k];
        if (nx < 0 || nx > 7) continue;
        if (ny < 0 || ny > 7) continue;
        if (nx == x && ny == y) ok = 0;
        if (nx == xx && ny == yy) ok = 0;
      }
      rs += ok;
    }
  cout << rs << '\n';
  return 0;
}
