#include <bits/stdc++.h>
using namespace std;
int main() {
  char str[3];
  cin >> str;
  int x = int(str[0] - 'a');
  int y = (str[1] - '1');
  int lef;
  int rig;
  int up;
  int down;
  if (x - 1 >= 0)
    lef = x - 1;
  else
    lef = x;
  if (x + 1 < 8)
    rig = x + 1;
  else
    rig = x;
  if (y - 1 >= 0)
    down = y - 1;
  else
    down = y;
  if (y + 1 < 8)
    up = y + 1;
  else
    up = y;
  int ans = (rig - lef + 1) * (up - down + 1) - 1;
  cout << ans << endl;
}
